专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 信息/网络安全

破译一段密文,感兴趣者可以看看。(已经看出部分规律)

发布时间:2011-07-03 07:09:29 文章来源:www.iduyao.cn 采编人员:星星草
求助破译一段密文,感兴趣者可以看看。(已经看出部分规律)
明文是一段2000字符的与信息安全相关的文章,加密人员通过自己的算法进行加密,加密后的密文和明文的字符数一样多。
加密人员犯了一个错误,那就是没有剔除空格和字符,我已经分析出了部分规律:

密文 所对应明文
小写 —— 大写
数字 —— 标点(包括空格)
大写 —— 小写
8 —— 空格

  密文如下:
9WBEL9mYGUHMQ………………

CSDN帖子里不让放太长的字符,密文全文的下载地址如下:
http://sgzl.ys168.com/
非常谢谢

------解决方案--------------------
已经破解完成,包括加密密钥和算法。我写了一个用于解密的VBScript:
Decrypt.vbs
VBScript code
Option Explicit

Sub Decrypt(SecretFile, PlainFile)
    Const ForReading = 1, ForWriting = 2, ForAppending = 3
    Dim fso, fSecret, fPlain, strInput, keys, strSecret, strPlain, lCount, strChar, ascChar
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.FileExists(SecretFile) Then
        MsgBox "程序找不到密码文件,无法进行解密。", , "密码文件丢失"
        Exit Sub
    End If
    Set fSecret = fso.OpenTextFile(SecretFile, ForReading)
    Do
        If Not fso.FileExists(PlainFile) Then Exit Do
        strInput = InputBox("文件“" & PlainFile & "”已经存在,请重新指定明码文件名。", "文件重名")
        If strInput = "" Then Exit Sub
        PlainFile = strInput
    Loop
    Set fPlain = fso.CreateTextFile(PlainFile, True)
    keys = Array(2, 3, 1, 2, 1, 1, 2, 3, 2, 3, 2, 1, 2)
    strSecret = fSecret.ReadAll
    For lCount = 0 To Len(strSecret) - 1
        strChar = Mid(strSecret, lCount + 1, 1)
        ascChar = Asc(strChar)
        If ascChar = 48 Then '0
            strPlain = strPlain & Chr(10)
        ElseIf ascChar > 48 And ascChar < 52 Then '1-3
            ascChar = ascChar - keys(lCount Mod 13) + 74 '42=-48+122
            strPlain = strPlain & Chr(ascChar)
        ElseIf ascChar > 64 And ascChar < 91 Then 'A-Z
            ascChar = ascChar - keys(lCount Mod 13)
            strPlain = strPlain & LCase(Chr(ascChar))
        ElseIf ascChar > 96 And ascChar < 123 Then 'a-z
            ascChar = ascChar + keys(lCount Mod 13)
            strPlain = strPlain & UCase(Chr(ascChar))
        Else 'other
            strPlain = strPlain & " "
        End If
    Next
    fPlain.Write strPlain
    fPlain.Close
    fSecret.Close
    Set fPlain = Nothing
    Set fSecret = Nothing
    Set fso = Nothing
    MsgBox "解密完成,明码已保存在“" & PlainFile & "”文件中。", , "解密完成"
End Sub


Const SecretFileName = "SecretCode.txt", PlainFileName = "PlainCode.txt"
Decrypt SecretFileName, PlainFileName
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: