小编Aur*_*rum的帖子

我的Salting和SHA-512哈希密码的实现是否正确/安全?

我的Salting和SHA-512哈希密码的实现是否正确/安全?

我知道我应该在盐渍密码上迭代算法几次.除此之外,我应该实施什么才能使其安全或者这足够了?

        public static String[] SHA512(String password)
{
    //Generates the salt
    SecureRandom saltRandomizer = new SecureRandom();
    byte[] salt = new byte[64]; //The same size as the output of SHA-512 (512 bits = 64 bytes)
    saltRandomizer.nextBytes(salt);
    String encodedSalt = Base64.encodeToString(salt, Base64.DEFAULT);


    //Prepends the salt to the password
    String saltedPassword = encodedSalt + password;

    //Hashed the salted password using SHA-512
    MessageDigest digester;
    byte[] digest = null;
    try {
        digester = MessageDigest.getInstance("SHA-512");
        digester.reset();
        digester.update(saltedPassword.getBytes());
        digest = digester.digest();
    } catch (NoSuchAlgorithmException e) {
        System.out.println("No …
Run Code Online (Sandbox Code Playgroud)

java security cryptography salt sha512

2
推荐指数
1
解决办法
5735
查看次数

while(getchar()!=多个参数)

如何使用getchar作为while循环的条件,并在(c = getchar())= EOF或'\n'或'\ 0'时终止它.

我试过了:

int c=0;
while((c=getchar()) != EOF || '\n' || '\0'){
putchar();
}
Run Code Online (Sandbox Code Playgroud)

哪个不起作用,如果我进入:天气(+输入).它没有终止循环.

我怎样才能做到这一点?

恩赐我

c while-loop getchar

0
推荐指数
1
解决办法
1538
查看次数

标签 统计

c ×1

cryptography ×1

getchar ×1

java ×1

salt ×1

security ×1

sha512 ×1

while-loop ×1