小编And*_*ell的帖子

一次性密码(OTP)C#到Java转换代码

去年我在C#中编写了一次性密码(OTP)生成器.现在我需要在Java中使用OTP生成器,但是我找不到Java中的等效函数.

这是我去年写的代码:(我知道这个OTP的安全性很低,但我不需要防弹的代码)

SHA1CryptoServiceProvider hash = new SHA1CryptoServiceProvider(); //first hash with sha1
byte[] hashPass = hash.ComputeHash(Encoding.ASCII.GetBytes(pass)); //pass is entered by user
HMACMD5 hma = new HMACMD5(hashPass); // use the hashed value as a key to hmac
OTPass = hma.ComputeHash(Encoding.ASCII.GetBytes(email + Counter(email)));// generate OTPass, Counter(email) is the counter of the user taken from database
increaseCounter(email); // updating the counter
this.SetLog(this.GetLog() + Environment.NewLine + "OTPass Generated: " + BitConverter.ToString(OTPass)); // OTP
Run Code Online (Sandbox Code Playgroud)

这是我试图将C#转换为的Java代码:(这只是SHA1部分,我找不到如何用Java编写HMAC-MD5)

import java.io.*;
import java.security.*;

public class otp {

/**
 * @param …
Run Code Online (Sandbox Code Playgroud)

c# java md5 hmac

6
推荐指数
1
解决办法
3932
查看次数

存储在变量中的函数?使用Javascript

有人可以解释一下这个符号在javascript中是什么吗?什么是功能(d)在做什么?在这个程序中,似乎x被以下调用,但我不知道这意味着什么.提前致谢...

x = function(d) { return d.x * width / mx; };

// later....
 x({x: .9}); // call
Run Code Online (Sandbox Code Playgroud)

javascript

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

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

标签 统计

c# ×1

drawing ×1

hmac ×1

java ×1

javascript ×1

md5 ×1

mockups ×1