将String转换为Integer [英] Convert a String into Integer

查看:541
本文介绍了将String转换为Integer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是VB的neewbie程序员。

我创建了一个链接到MAC地址的算法,并返回一个写入的密钥一个指定的文本框让程序运行(只是PC的一个简单许可证)

我想生成的密钥必须从一个新的算法生成,该算法包含来自文本框中写入的电子邮件的标记。



指定,如何在数字中转换像example123@example.com这样的字符串???



亲切地,

Nick

解决方案

看看 String.GetHashCode [ ^ ]



最好使用某种 KeyedHashAlgorithm [ ^ ]



最好的问候

Espen Harlinn


检查out



System.Text .AsciiEncoding.GetBytes [ ^ ]







Convert.ToBase64String [ ^ ]



后者将其转换为基数 - 64号可以转换回文本。然而,实际上没有办法将文本转换为数字,使该数字适合数字结构,并且对于文本是唯一的。 BigInteger不足以处理那么多数据。



您可以编写自己的散列函数,但即使这样,也难以保证唯一的字符串。

最简单的方法是获取其哈希码:



http://msdn.microsoft.com/en-us/library/system.string.gethashcode.aspx [ ^ ]



或者您可以尝试不同的散列算法。


Hello everyone , i'm a neewbie programmer with VB .
I created an algoritm that is linked to the MAC address and that return me a key that writed in an specify textbox let the programm run (just a simple licence unique for PC )
I'd like that the key generated must be generated from a new algoritm that contains something token from the email written in a textbox .

Specify , how can i convert a string like example123@example.com in a number ???

Cordially,
Nick

解决方案

Have a look at String.GetHashCode[^]

It would proably be best to use some sort of KeyedHashAlgorithm[^]

Best regards
Espen Harlinn


Check out

System.Text.AsciiEncoding.GetBytes[^]

and

Convert.ToBase64String[^]

The latter of which converts it to a base-64 number that can be converted back to the text. However there really isn't a way to convert the text to a number, have that number fit inside a numerical structure, and be unique to the text. BigInteger isn't big enough to handle that much data.

You could write your own hashing function, but even then its hard to guarantee a unique string.


The simplest way may be to get its hash code:

http://msdn.microsoft.com/en-us/library/system.string.gethashcode.aspx[^]

Or you could try a different hashing algorithm.


这篇关于将String转换为Integer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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