将二进制转换为字符串 [英] Convert Binary to String

查看:69
本文介绍了将二进制转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个以二进制存储的密码转换为正常的 ASCII 格式,以便我可以读取它.我需要一个 VBscript,脚本也应该返回这个解密密码

I want to convert a password which is stored in binary to normal ASCII form so that i can read it. I need a VBscript for that and script should also return this de-crypted password

例如:加密的二进制密码:00110001 00110010 00110011 00110100

Eg: Encrypted Binary password: 00110001 00110010 00110011 00110100

解密原始密码:1234

De-crypted Original password : 1234

我试过了

'Binary contains the binary password
dim S
For I = 1 To LenB(Binary)
S = S & Chr(AscB(MidB(Binary, I, 1)))
Next
MSGBOX S

但是输出是

0

如何实现这一点.请帮忙!!

How can achieve this. Please help!!

推荐答案

如果我是对的,您所追求的只是将二进制数转换为十进制数(例如 0100 -> 4)?

If I'm right, all you're after is converting a binary number to decimal (eg 0100 -> 4)?

dim binary, n, s
binary= "00110001"

For s = 1 To Len(binary)
    n = n + (Mid(binary, Len(binary) - s + 1, 1) * (2 ^ (s - 1)))
Next 's

WScript.Echo binary & " = " & n

输出

00110001 = 49

00110001 = 49

从这里转换:http://www.vb-helper.com/howto_decimal_to_binary.html

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

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