? ?廣州龍躍自動化專業(yè)破解解密各類plc加密,全國24小時聯系手機:18520649527 【關技術】 微信:guanshiyou009如有任何問題請打手機或者添加微信,謝謝支持
PLC解密,全國上門PLC解密維修找龍躍自動化PLC解密網vb編寫plc解密源碼,專業(yè)PLC解密師傅電話153 8444 7766;提供三菱plc解密,臺達plc解密,西門子plc解密,信捷plc解密等各類PLC解密vb編寫密碼程序及觸摸屏解密維修服務,【加微信:guanshiyou009】
VB 加密與解密的程序代碼
加密:
Private?Function JiaMi(ByVal varPass As String) As String '參數varPass是需要加密的文本內容
Dim varJiaMi As String * 20
Dim varTmp As Double
Dim strJiaMi As String
Dim I
For I = 1 To Len(varPass)
varTmp = AscW(Mid$(varPass, I, 1))
varJiaMi = Str$(((((varTmp * 1.5) / 5.6) * 2.7) * I))
strJiaMi = strJiaMi varJiaMi
Next?I
JiaMi = strJiaMi
End?Function
解密函數:
Private?Function JieMi(ByVal varPass As String) As String '參數varPass是需要解密的密文內容
Dim varReturn As String * 20
Dim varConvert As Double
Dim varFinalPass As String
Dim varKey As Integer
Dim varPasslenth As Long
varPasslenth = Len(varPass)
For I = 1 To varPasslenth / 20
varReturn = Mid(varPass, (I - 1) * 20 + 1, 20)
varConvert = Val(Trim(varReturn))
varConvert = ((((varConvert / 1.5) * 5.6) / 2.7) / I)
varFinalPass = varFinalPass ChrW(Val(varConvert))
Next?I
JieMi = varFinalPass
End?Function
擴展資料:
注意事項
編寫加密程序,將用戶輸入的一個英文句子加密為加密字符串,然后輸出加密字符串。假設句子長度不超過100個字符。
根據給定的句子加密函數原型SentenceEncoding,編寫函數SentenceEncoding調用給定的字符加密函數CharEncoding完成句子加密。
然后,編寫主程序提示用戶輸入英文句子,然后調用函數SentenceEncoding對句子加密,最后輸出加密后的句子。
字符加密規(guī)則為大寫字母和小寫字母均加密為其補碼, 我們定義ASCII碼值相加為’A’+’Z’即155的兩個大寫字母互為補碼,ASCII碼值相加為’a’+’z’即219的兩個小寫字母互為補碼。
空格用@代替,句號以#代替,其它字符用句點代替。
函數原型:
void SentenceEncoding(char *soure,char *code);
功能:對待加密字符串source加密后保存加密字符串到code.
參數:char *soure,指向待加密句子的字符串指針;
char *code 指向加密字符串的字符串指針;
字符加密函數代碼。
[img]能給我發(fā)個VB與三菱PLC通訊的源代碼實例嗎,非常感謝啊
得說明是什么型號的PLC啊,串口還是網口,VB6還是VB.NET?
算了,寫段代碼,VB.NET與Q系列以太網通訊的:
Imports?System.Net
Imports?System.Runtime.InteropServices
Public?Class?Form1
????Dim?Handle1?As?Int32
????Dim?EntLink1?As?Boolean
????Dim?ScanCount1?As?Long
????Dim?PLC?As?New?EntQsPlc_Asc.PlcClient'EntQsPlc_ASC.DLL是Q系列以太網通訊組件
????Public?Declare?Function?timeGetTime?Lib?"winmm.dll"?()?As?UInt32
????Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load
????????Me.CenterToScreen()
????????cmbReadMry.Items.Clear()
????????cmbReadMry.Items.Add("X")
????????cmbReadMry.Items.Add("Y")
????????cmbReadMry.Items.Add("M")
????????cmbReadMry.Items.Add("D")
????????cmbReadMry.Items.Add("R")
????????cmbReadMry.Items.Add("Z")
????????'
????????cmbWriteMry.Items.Clear()
????????cmbWriteMry.Items.Add("X")
????????cmbWriteMry.Items.Add("Y")
????????cmbWriteMry.Items.Add("M")
????????cmbWriteMry.Items.Add("D")
????????cmbWriteMry.Items.Add("R")
????????cmbWriteMry.Items.Add("Z")
????????'
????????cmbBitMry.Items.Clear()
????????cmbBitMry.Items.Add("X")
????????cmbBitMry.Items.Add("Y")
????????cmbBitMry.Items.Add("M")
????????'
????????cmbReadType.Items.Clear()
????????cmbReadType.Items.Add("INT16")
????????cmbReadType.Items.Add("UINT16")
????????cmbReadType.Items.Add("DINT32")
????????cmbReadType.Items.Add("HEX32")
????????cmbReadType.Items.Add("REAL32")
????????cmbReadType.Items.Add("BIN16")
????????'
????????cmbWriteType.Items.Clear()
????????cmbWriteType.Items.Add("INT16")
????????cmbWriteType.Items.Add("UINT16")
????????cmbWriteType.Items.Add("DINT32")
????????cmbWriteType.Items.Add("HEX32")
????????cmbWriteType.Items.Add("REAL32")
????????cmbWriteType.Items.Add("BIN16")
????????cmbReadMry.SelectedIndex?=?3
????????cmbWriteMry.SelectedIndex?=?3
????????cmbBitMry.SelectedIndex?=?2
????????cmbReadType.SelectedIndex?=?0
????????cmbWriteType.SelectedIndex?=?0
????????lstRead.Items.Clear()
????????txtWrite.Text?=?""
????????'
????????cmbCmdType.SelectedIndex?=?0
????End?Sub
????Private?Sub?butLink_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butLink.Click
????????Dim?re?As?Short
????????Dim?restr?As?String?=?""
????????re?=?PLC.EntLink(Trim(txtLocalIP.Text),?Val(txtLocalPort.Text),?Trim(txtRemoteIP.Text),?Val(txtRemotePort.Text),?"DEMO",?Handle1,?1000,?CBool(cmbCmdType.SelectedIndex))
????????txtReLink.Text?=?re.ToString
????????If?re?=?0?Then
????????????EntLink1?=?True
????????????MsgBox("PLC聯接成功!?")
????????Else
????????????EntLink1?=?False
????????????MsgBox("PLC聯接失敗:?"??restr)
????????End?If
????End?Sub???????????
????Private?Sub?butClose_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butClose.Click
????????Dim?re?As?Short
????????If?Not?EntLink1?Then
????????????MsgBox("還未與PLC建立聯接!")
????????????Exit?Sub
????????End?If
????????re?=?PLC.DeLink(Handle1)
????????txtReClose.Text?=?re.ToString
????End?Sub
????Private?Sub?butRead_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butRead.Click
????????Dim?re?As?Short
????????Dim?i?As?Short
????????Dim?RD()?As?Object
????????ReDim?RD(Val(txtReadCnt.Text?-?1))
????????If?Not?EntLink1?Then
????????????MsgBox("還未與PLC建立聯接!")
????????????'?Exit?Sub
????????End?If
????????Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbReadMry.SelectedIndex?+?1
????????Dim?typ?As?EntQsPlc_Asc.PlcClient.DataType?=?cmbReadType.SelectedIndex?+?1
????????re?=?PLC.CmdRead(Handle1,?mry,?typ,?CInt(txtReadAdd.Text),?CUShort(txtReadCnt.Text),?RD)
????????txtReRead.Text?=?re.ToString
????????lstRead.Items.Clear()
????????For?i?=?0?To?UBound(RD)?Step?1
????????????If?Not?IsNothing(RD(i))?Then?lstRead.Items.Add(RD(i))
????????Next?i
????????If?re??0?Then
????????????Timer1.Enabled?=?False
????????????butScan.Text?=?"Cycle?R/W"
????????End?If
????End?Sub
????Private?Sub?butWrite_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butWrite.Click
????????Dim?re?As?Short
????????Dim?i?As?Short
????????Dim?temp()?As?String
????????Dim?WD()?As?Object
????????If?Not?EntLink1?Then
????????????MsgBox("還未與PLC建立聯接!")
????????????Exit?Sub
????????End?If
????????ReDim?WD(Val(txtWriteCnt.Text)?-?1)
????????temp?=?Split(txtWrite.Text,?vbCrLf)
????????For?i?=?0?To?UBound(WD)?Step?1
????????????If?i??UBound(temp)?Then
????????????????WD(i)?=?0
????????????Else
????????????????WD(i)?=?Trim(temp(i))
????????????End?If
????????Next?i
????????Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbWriteMry.SelectedIndex?+?1
????????Dim?typ?As?EntQsPlc_Asc.PlcClient.DataType?=?cmbWriteType.SelectedIndex?+?1
????????re?=?PLC.CmdWrite(Handle1,?mry,?typ,?CInt(txtWriteAdd.Text),?CUShort(txtWriteCnt.Text),?WD)
????????txtReWrite.Text?=?re.ToString
????????If?re??0?Then
????????????Timer1.Enabled?=?False
????????????butScan.Text?=?"Cycle?R/W"
????????End?If
????End?Sub
????
????
????Private?Sub?butScan_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butScan.Click
????????If?Not?EntLink1?Then
????????????MsgBox("還未與PLC建立聯接!")
????????????Exit?Sub
????????End?If
????????Timer1.Enabled?=?Not?Timer1.Enabled
????????If?Timer1.Enabled?Then
????????????ScanCount1?=?0
????????????butScan.Text?=?"Stop?R/W"
????????Else
????????????butScan.Text?=?"Cycle?R/W"
????????End?If
????End?Sub
????Private?Sub?Timer1_Tick(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Timer1.Tick
????????Timer1.Enabled?=?False
????????Dim?tim?As?Integer?=?timeGetTime
????????If?Not?EntLink1?Then
????????????MsgBox("還未與PLC建立聯接!")
????????????Exit?Sub
????????End?If
????????'
????????Call?butRead_Click(Nothing,?Nothing)
????????Call?butWrite_Click(Nothing,?Nothing)
????????'
????????If?(Val(txtReRead.Text)??0)?Or?(Val(txtReWrite.Text)??0)?Then
????????????butScan.Text?=?"Cycle?R/W"
????????????Exit?Sub
????????Else
????????????ScanCount1?+=?1
????????????txtScanCnt.Text?=?ScanCount1
????????????txtScanPrd.Text?=?(timeGetTime?-?tim)??"ms"
????????End?If
????????Timer1.Enabled?=?True
????End?Sub
????Private?Sub?butBitTest_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitTest.Click
????????If?Not?EntLink1?Then
????????????MsgBox("還未與PLC建立聯接!")
????????????Exit?Sub
????????End?If
????????Dim?rd?As?Boolean
????????Dim?re?As?Short
????????Dim?mry?As?EntQsPlc_Asc.PlcClient.PlcMemory?=?cmbBitMry.SelectedIndex?+?1
????????re?=?PLC.Bit_Test(Handle1,?mry,?CUShort(txtBitAdd.Text),?rd)
????????txtBitTest.Text?=?rd
????????txtReBit.Text?=?re
????End?Sub
????Private?Sub?butBitSet_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitSet.Click
????????If?Not?EntLink1?Then
????????????MsgBox("還未與PLC建立聯接!")
????????????Exit?Sub
????????End?If
????????Dim?re?As?Short
????????re?=?PLC.Bit_Set(Handle1,?cmbBitMry.SelectedIndex?+?1,?Val(txtBitAdd.Text))
????????txtReBit.Text?=?re
????End?Sub
????Private?Sub?butBitRst_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?butBitRst.Click
????????If?Not?EntLink1?Then
????????????MsgBox("還未與PLC建立聯接!")
????????????Exit?Sub
????????End?If
????????Dim?re?As?Short
????????re?=?PLC.Bit_Reset(Handle1,?cmbBitMry.SelectedIndex?+?1,?Val(txtBitAdd.Text))
????????txtReBit.Text?=?re
????End?Sub
End?Class
用VB寫個簡單加密/解密程序
'圖上的控件,你就照著擺上去,然后再把以下代碼拷進去,就OK了
Dim lg As Integer
'加密
Private Sub Command1_Click()
Text2 = ""
Dim a(), b() As String
lg = Len(Text1)
ReDim a(lg), b(lg)
For i = 1 To lg
a(i) = Mid(Text1, i, 1)
b(i) = AscW(a(i)) Xor 4
Text2 = Text2 ChrW(b(i))
Next
End Sub
'解密
Private Sub Command2_Click()
Text3 = ""
Dim a(), b() As String
lg = Len(Text2)
ReDim a(lg), b(lg)
For i = 1 To lg
a(i) = Mid(Text2, i, 1)
b(i) = AscW(a(i)) Xor 4
Text3 = Text3 ChrW(b(i))
Next
End Sub
? ?廣州龍躍自動化專業(yè)破解解密各類plc加密,全國24小時聯系手機:18520649527 【關技術】 微信:guanshiyou009如有任何問題請打手機或者添加微信,謝謝支持