1

指定された文字列に対して256ビットの文字列出力を可能にするハッシュ関数(できれば実装)を教えてください。

事前にどうもありがとうございました

4

1 に答える 1

2
MessageDigest md   = MessageDigest.getInstance("SHA-256"); //make sure it exists, there are other algorithms, but I prefer SHA for simple and relatively quick hashing
String strToEncode = "Hello world";
md.update(strToEncode.getBytes("UTF-8")); //I'd rather specify the encoding. It's platform dependent otherwise. 
byte[] digestBuff = md.digest();

digestBuffには、消化されたバイトが含まれます。

于 2012-06-29T13:22:25.490 に答える