public static string Encode(string input, byte[] key) { byte[] byteArray = Encoding.ASCII.GetBytes(input); using(var myhmacsha1 = new HMACSHA1(key)) { var hashArray = myhmacsha1.ComputeHash(byteArray); return hashArray.Aggregate("", (s, e) => s + String.Format("{0:x2}",e), s => s ); } }
@Override public void update(long i) { tmp[0] = (byte) (i >>> 24); tmp[1] = (byte) (i >>> 16); tmp[2] = (byte) (i >>> 8); tmp[3] = (byte) i; update(tmp, 0, 4); }
@Override public BaseMAC create() { return new BaseMAC(algorithm, bSize, defBSize, etm); } }
private void putMAC(SSHPacket buffer, int startOfPacket, int endOfPadding) { buffer.wpos(endOfPadding + mac.getBlockSize()); mac.update(seq); mac.update(buffer.array(), startOfPacket, endOfPadding); mac.doFinal(buffer.array(), endOfPadding); }
private HMACSHA2512 initHmac() { HMACSHA2512 hmac = new HMACSHA2512(); hmac.init("paishiengu1jaeTie5OoTu2eib7Kohqueicie7ahLohfoothahpeivi5weik1EiB".getBytes(CHARSET)); return hmac; } }
private HMACSHA196 initHmac() { HMACSHA196 hmac = new HMACSHA196(); hmac.init("et1Quo5ooCie6theel8i".getBytes(CHARSET)); return hmac; } }
private HMACSHA2256 initHmac() { HMACSHA2256 hmac = new HMACSHA2256(); hmac.init("koopiegh4reengah1que9Wiew7ohahPh".getBytes(CHARSET)); return hmac; } }
@Override public MAC create() { return new HMACSHA2256(); }
@Override public MAC create() { return new HMACSHA196(); }
@Override public MAC create() { return new HMACMD5(); }
@Override public MAC create() { return new HMACSHA2512(); }
@Override public MAC create() { return new HMACMD596(); }
@Override void setAlgorithms(Cipher cipher, MAC mac, Compression compression) { super.setAlgorithms(cipher, mac, compression); macResult = new byte[mac.getBlockSize()]; }
@Override public MAC create() { return new HMACRIPEMD160(); }
@Override public byte[] doFinal() { return resizeToHashSize(mac.doFinal()); }
@Override public MAC create() { return new HMACSHA1(); }