帮助将SHA1哈希转换为打包的base64编码的字符串 [英] Help converting a SHA1 hash to a packed base64 encoded string

查看:106
本文介绍了帮助将SHA1哈希转换为打包的base64编码的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,
我正在为我的ISP LDAP服务器使用接口,因此我可以将本地用户帐户同步到我的电子邮件帐户(由isp托管).我以前已经在php中完成了此项目,但想使用c#移至.net.该过程运行良好,直到需要打包字符串为止.在php中,我必须进行打包("H *")(首先是高位半字节)是我在base64编码之前的哈希值.我不确定如何在c#中执行此操作,甚至不确定它的含义.我知道什么是半字节,半字节(4位).我不知道哪个是高半字节?我假设正常的存储方法是先存储低位半字节?我并不是真正在寻找代码,而是更多地解释如何首先将十六进制值(例如0x4a)转换为二进制高半字节.
谢谢!

Greetings,
Im working on an interface for my ISPs LDAP server so i can magically sychronize my local user accounts to my email accounts (hosted by my isp).  i have previously done this project in php, but wanted to move over to .net using c#.

the process works fine until i need to pack the string ..  in php i have to pack("H*") ( high nibble first) my hash before the base64 encode.. im not sure how to do that in c#, or really even what it means.  i know what a nibble is, half a byte (4 bits).  what i dont know is which nibble is the high nibble?  im assuming the normal storage method is to store the low nibble first?  im not really looking for code, but more for an explaination of how to convert a hex value  (0x4a for example) to binary high nibble first. 
Thanks!

推荐答案

杰里,

试试吧:

Hi Jerry,

Try this:

byte b = 0x4a;

Console.WriteLine("High {0:x}", b >> 4);
Console.WriteLine("Low {0:x}", b & 0xf);


关于,


Regards,

Jie


这篇关于帮助将SHA1哈希转换为打包的base64编码的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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