62,025
社区成员
发帖
与我相关
我的任务
分享
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
namespace Plugin
{
public class Cfs
{
public static string ConvertCode(string CodeStr)
{
long CodeLen = 32;
long CodeSpace = 0;
int cecr = 0;
int cecb = 0;
int cec = 0;
Double NewCode = 1;
string CfsStr = "";
try
{
CodeSpace = CodeLen - CodeStr.Length;
if (!(CodeSpace < 1))
{
for (cecr = 1; cecr <= CodeSpace; cecr++)
{
CodeStr += char.ConvertFromUtf32(21);
}
}
long Been = 0;
for (cecb = 1; cecb <= CodeLen; cecb++)
{
Been = CodeLen + ConvertAscii(CodeStr.Substring(cecb - 1, 1)) * cecb;
NewCode = Convert.ToDouble(NewCode * Been);
}
CodeStr = NewCode.ToString().ToUpper();
string NewCode1 = "";
for (cec = 1; cec <= CodeStr.Length; cec++)
{
if (CodeStr.Length - 1 <= cec)
{
NewCode1 += CfsCode(CodeStr.Substring(cec - 1));
}
else
{
NewCode1 += CfsCode(CodeStr.Substring(cec - 1, 3));
}
}
for (cec = 20; cec <= NewCode1.Length - 18; cec += 2)
{
CfsStr += NewCode1.Substring(cec - 1, 1);
}
}
catch(Exception ex)
{ Util.Wlog(ex.ToString());
}
return CfsStr;
}
private static string CfsCode(string Word)
{
string CfsCodeStr = "";
int cc = 0;
for (cc = 1; cc <= Word.Length; cc++)
{
CfsCodeStr = CfsCodeStr + ConvertAscii(Word.Substring(cc - 1, 1));
}
//CfsCodeStr = Conversion.Hex(CfsCodeStr);
CfsCodeStr = string.Format("{0:0x000}", int.Parse(CfsCodeStr));
return CfsCodeStr;
}
private static int ConvertAscii(string text)
{
byte[] array = new byte[1];
array = System.Text.Encoding.ASCII.GetBytes(text);
int asciicode = (int)(array[0]);
return asciicode;
//throw new NotImplementedException();
}
}
}
Public Class CfsCode
Function Cfs(CodeStr) as string
Dim CodeLen as integer = 32
Dim CodeSpace as long
Dim cecr as integer
Dim cecb as integer
Dim cec as integer
Dim NewCode as Double = 1
Dim CfsStr as string = ""
CodeSpace = CodeLen - Len(CodeStr)
If Not CodeSpace < 1 Then
For cecr = 1 To CodeSpace
CodeStr += Chr(21)
Next
End If
Dim Been as Double
For cecb = 1 To CodeLen
Been = CodeLen + Ctype(Asc(Mid(CodeStr,cecb,1)),integer) * cecb
NewCode = NewCode * Been
Next
CodeStr = Ctype(NewCode,String)
Dim NewCode1 as string = ""
For cec = 1 To Len(CodeStr)
NewCode1 += CfsCode(Mid(CodeStr,cec,3))
Next
For cec = 20 To Len(NewCode1) - 18 Step 2
CfsStr += Mid(NewCode1,cec,1)
Next
Return CfsStr
End Function
Private Function CfsCode(Word) as string
Dim CfsCodeStr as string
Dim cc as integer
For cc = 1 To Len(Word)
CfsCodeStr = CfsCodeStr & Ctype(Asc(Mid(Word,cc,1)),string)
Next
CfsCodeStr = Hex(CfsCodeStr)
Return CfsCodeStr
End Function
End Class