如何排序字符串长度 [英] how to sort string length

查看:74
本文介绍了如何排序字符串长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好frnd我有一个字符串变量。而我在申报时并不知道它的大小。它的长度可能大于25或小于25.

i想要转换此字符串只有25个字符。

amd如果字符串值相同则始终生成相同的字符。

请任何人给我一些想法。

感谢adv。

hello frnd I have a string variable. and I dont know it's size on the time of declaration. it's length may be grater than 25 or less than 25.
i want to convert this string is only 25 charater.
amd if string value is same the it always generate same charater.
please any one give me some ideas.
Thanks in adv.

推荐答案

你应该看一下根据学校名称+学校地址生成哈希。选择25个字符的问题应该易于处理。



你想要/需要哈希的安全将决定你使用的具体技术,比如使用salt(在散列之前附加或预先挂起,随机字符串到每个键源)。



有一个很好的微软一步一步关于从字符串生成哈希的C#教程:[ ^ ]。本教程包含一个关于如何比较两个哈希(可以使用Linq进行简化)的部分。
You should look into generating Hashes based on School Name + School Address. The issue of which 25 characters to select should be easy to handle.

How "secure" you want/need the Hashes to be will dictate the specific techniques you use, like using "salt" (appending, or pre-pending, a random string to each key-source before hashing).

There's a good Microsoft step-by-step C# tutorial on generating Hashes from strings here: [^]. This tutorial includes a section on how you compare two Hashes (which could be simplified using Linq).


Hi Shamboo,



我想你想从字符串中获取25个字符,字符串可能有25个或多或少的字符..如果我是对的,你可以试试这个



所以这里是我试过的,这可能是有用的并保持参考



Hi Shamboo,

I think you want to get 25 characters from the string, string may have 25 more or less characters.. If I am right, you can try this

So here is what I have tried, which might be useful and keep it as refernce

string encodeStr = @"!#


%&'() * +, - 。/ 0123456789:;< =>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ [\] ^ _` abcdefghijklmnopqrstuvwxyz {|}〜;

string decodeStr = @ @ ABCDEFGHIJKLMNO0123456789:;< =>?pqrstuvwxyz {|}〜!#
%&'()*+,-./0123456789:;<=>? @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; string decodeStr = @"@ABCDEFGHIJKLMNO0123456789:;<=>? pqrstuvwxyz{|}~!#


这篇关于如何排序字符串长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆