发布网友 发布时间:2022-05-11 13:39
共1个回答
热心网友 时间:2023-10-13 11:04
摘要一对VBA加密解密函数,与大家共享Public Sub Cipher(ByVal password As String, ByVal from_text As String, to_text As String)'加密Const MIN_ASC = 32 ' Space.Const MAX_ASC = 126 ' ~.Const NUM_ASC = MAX_ASC - MIN_ASC + 1Dim offset As LongDim str_len As IntegerDim i As IntegerDim ch As Integer offset = NumericPassword(password) Rnd -1 Randomize offset str_len = Len(from_text) For i = 1 To str_len ch = Asc(Mid$(from_text, i, 1)) If ch >= MIN_ASC And ch <= MAX_ASC Then ch = ch - MIN_ASC offset = Int((NUM_ASC + 1) * Rnd) ch = ((ch + offset) Mod NUM_ASC) ch = ch + MIN_ASC to_text = to_text & Chr$(ch) End If Next iEnd SubPublic Sub Decipher(ByVal password As String, ByVal from_text As String, to_text As String) '解密Const MIN_ASC = 32 ' Space.Const MAX_ASC = 126 ' ~.Const NUM_ASC = MAX_ASC - MIN_ASC + 1Dim offset As LongDim str_len As IntegerDim i As IntegerDim ch As Integer of咨询记录 · 回答于2021-11-08vba中怎样定义加密狗getid函数您好,您的问题我已经看到了,正在整理答案,请稍等一会儿哦~您好,您的问题我已经看到了,正在整理答案,请稍等一会儿哦~一对VBA加密解密函数,与大家共享Public Sub Cipher(ByVal password As String, ByVal from_text As String, to_text As String)'加密Const MIN_ASC = 32 ' Space.Const MAX_ASC = 126 ' ~.Const NUM_ASC = MAX_ASC - MIN_ASC + 1Dim offset As LongDim str_len As IntegerDim i As IntegerDim ch As Integer offset = NumericPassword(password) Rnd -1 Randomize offset str_len = Len(from_text) For i = 1 To str_len ch = Asc(Mid$(from_text, i, 1)) If ch >= MIN_ASC And ch <= MAX_ASC Then ch = ch - MIN_ASC offset = Int((NUM_ASC + 1) * Rnd) ch = ((ch + offset) Mod NUM_ASC) ch = ch + MIN_ASC to_text = to_text & Chr$(ch) End If Next iEnd SubPublic Sub Decipher(ByVal password As String, ByVal from_text As String, to_text As String) '解密Const MIN_ASC = 32 ' Space.Const MAX_ASC = 126 ' ~.Const NUM_ASC = MAX_ASC - MIN_ASC + 1Dim offset As LongDim str_len As IntegerDim i As IntegerDim ch As Integer of