VB6.0通过MySQL Connector/ODBC连接MySQL
在 Visual Basic 6.0 中连接到 MySQL 数据库需要使用适当的数据库连接库。通常情况下,可以使用 MySQL 的官方连接库,即 MySQL Connector/ODBC 或 MySQL Connector/NET,在 VB6.0 中连接 ...
予人玫瑰,手有余香。1aEbBxZTjjXeyyOhpHKIuVQ
在 Visual Basic 6.0 中连接到 MySQL 数据库需要使用适当的数据库连接库。通常情况下,可以使用 MySQL 的官方连接库,即 MySQL Connector/ODBC 或 MySQL Connector/NET,在 VB6.0 中连接 ...
项目中报表功能的需求越来越多,急迫开发一款集成于SCADA的通用报表。RA的SE13版已经支持.NET控件,正好有机会来开发一款报表控件。 概况 基本需求 自动储存数据,并将数据定时导出或者定时打印。 根据最基本的需求,要实现功能,需要有执行动作的功能,也...
项目中报表功能的需求越来越多,急迫开发一款集成于SCADA的通用报表。 RA的FactoryTalk View SE 13版已经支持.NET控件,正好有机会来开发一款报表控件。 该控件不只可以用于SE,也可以用于WINCC。 概况 基本需求 自动储存数据,...
在上一篇文章末尾后记中记录了RA FTView SE控件事件的响应方法,我在后续制作控件的时候,发现事件参数的传递需要有特定的编写方式,记录一下: VS控件事件 事件编写如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<DefaultEvent("MenuItemClick")> Public Class KNavMenu Inherits TreeView Public Event MenuItemClick As EventHandler Private Sub ShowSelectedNode() Dim args As New ThresholdReachedEventArgs With { .nodeName = SelectedNode.Name, .nodePath = SelectedNode.FullPath, .nodeIndex = SelectedNode.ToolTipText } RaiseEvent MenuItemClick(SelectedNode, args) End Sub End Class Class ThresholdReachedEventArgs Inherits EventArgs Public Property nodeName As String Public Property nodePath As String Public Property nodeIndex As Integer End Class |
SE中配置 ...
自FactoryTalk View SE 13版起Rockwell的这款SCADA软件开始支持.Net控件。大家可以使用更为丰富的控件的同时,也可以自行编写.Net控件以进行支持。 由于本人一直基于VB/VB.NET进行开发,因此以该语言给大家进行讲解。 ...
在.NET下常用OpenCV进行图像处理工作,而常用的OpenCV库有Emgu CV和OpenCvSharp。OpenCvSharp使用习惯比EmguCV更接近原始的OpenCV,有详细的使用样例供参考。因此在网上收集了一些OpenCV的应用。 准备工作 ...
1、Java版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
import java.io.UnsupportedEncodingException; import java.security.SecureRandom; import javax.crypto.spec.DESKeySpec; import javax.crypto.spec.IvParameterSpec; import Decoder.BASE64Decoder; import Decoder.BASE64Encoder; import javax.crypto.SecretKeyFactory; import javax.crypto.SecretKey; import javax.crypto.Cipher; public class MyDesc { public MyDesc() {} //测试 public static void main(String args[]) throws UnsupportedEncodingException { //待加密内容 String str = "{\"pid\":\"511025198710264794\",\"pname\":false}"; //密码,长度要是8的倍数 String password = "2018052400018841"; String result = MyDesc.encrypt(str.getBytes("UTF-8"),password); System.out.println("加密后:"+result); //uMI2SuMFepPhQxytg/ONQPwfCnlLZHYOQiuIY6u176gbgHCw8nD7u3fMV7IgSr5o //直接将如上内容解密 try { String decryResult = MyDesc.decrypt(result, password); System.out.println("解密后:"+decryResult); //{"pid":"511025198710264794","pname":false} } catch (Exception e1) { e1.printStackTrace(); } } /** * 加密 * @param datasource * @param password * @return */ public static String encrypt(byte[] datasource, String password) { String strIv = "12345678"; try{ SecureRandom random = new SecureRandom(); DESKeySpec desKey = new DESKeySpec(password.getBytes("UTF-8")); //创建一个密匙工厂,然后用它把DESKeySpec转换成 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); SecretKey securekey = keyFactory.generateSecret(desKey); //Cipher对象实际完成加密操作 Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); //用密匙初始化Cipher对象 IvParameterSpec param = new IvParameterSpec(strIv.getBytes()); cipher.init(Cipher.ENCRYPT_MODE, securekey, param); //现在,获取数据并加密 //正式执行加密操作 byte[] buf = cipher.doFinal(datasource); String utf8 = new BASE64Encoder().encodeBuffer(buf); return utf8; }catch(Throwable e){ e.printStackTrace(); } return null; } /** * 解密 * @param src * @param password * @return * @throws Exception */ public static String decrypt(String src, String password) throws Exception { String strIv = "12345678"; // DES算法要求有一个可信任的随机数源 SecureRandom random = new SecureRandom(); // 创建一个DESKeySpec对象 DESKeySpec desKey = new DESKeySpec(password.getBytes()); // 创建一个密匙工厂 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); // 将DESKeySpec对象转换成SecretKey对象 SecretKey securekey = keyFactory.generateSecret(desKey); // Cipher对象实际完成解密操作 Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); // 用密匙初始化Cipher对象 IvParameterSpec param = new IvParameterSpec(strIv.getBytes()); cipher.init(Cipher.DECRYPT_MODE, securekey, param); // 真正开始解密操作 byte[] dec = new BASE64Decoder().decodeBuffer(src); byte[] utf8 = cipher.doFinal(dec); String decryptedStr = new String(utf8, "UTF-8"); return decryptedStr; } } |
2、C#版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
using System; using System.Collections.Generic; using System.Linq; using System; using System.Linq; using System.Web.Script.Serialization; using System.Runtime.Serialization; using System.Dynamic; using System.Net; using System.IO; using System.Collections.Specialized; using System.Web; using System.Security.Cryptography; using System.Text; namespace testDESC { static class Test { /// <summary> /// 解密 /// </summary> /// <param name="encryptedString"></param> /// <param name="keyString"></param> /// <returns></returns> public static string Decrypt(string encryptedString, string keyString) { keyString = keyString.Substring(0, 8); byte[] btKey = Encoding.UTF8.GetBytes(keyString); byte[] btIv = Encoding.UTF8.GetBytes("12345678"); var des = new DESCryptoServiceProvider(); des.Mode = CipherMode.CBC;//这里指定加密模式为CBC des.Padding = PaddingMode.PKCS7; des.Key = btKey; des.IV = btIv; using (var ms = new MemoryStream()) { try { byte[] inData = Convert.FromBase64String(encryptedString); using (var cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write)) { cs.Write(inData, 0, inData.Length); cs.FlushFinalBlock(); } return Encoding.UTF8.GetString(ms.ToArray()); } catch (Exception ex) { return "-1"; // throw ex; } } } /// <summary> /// 加密 /// </summary> /// <param name="sourceString"></param> /// <param name="keyString"></param> /// <returns></returns> public static string Encrypt(string sourceString, string keyString) { keyString = keyString.Substring(0, 8); byte[] btIv = Encoding.UTF8.GetBytes("12345678"); byte[] btKey = Encoding.UTF8.GetBytes(keyString); try { DESCryptoServiceProvider des = new DESCryptoServiceProvider(); using (MemoryStream ms = new MemoryStream()) { byte[] inData = Encoding.UTF8.GetBytes(sourceString); using (CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(btKey, btIv), CryptoStreamMode.Write)) { cs.Write(inData, 0, inData.Length); cs.FlushFinalBlock(); } return Convert.ToBase64String(ms.ToArray()); } } catch { return "-1"; } } static void Main(string[] args) { string str = "{\"pid\":\"511025198710264794\",\"pname\":false}"; string re = Encrypt(str, "2018052400018841"); Console.WriteLine("加密:" + re); //uMI2SuMFepPhQxytg/ONQPwfCnlLZHYOQiuIY6u176gbgHCw8nD7u3fMV7IgSr5o string re1 = Decrypt(re, "2018052400018841"); Console.WriteLine("解密:" + re1); //{"pid":"511025198710264794","pname":false} } } } |
3、VB.NET版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
Imports System.IO Imports System.Security.Cryptography Imports System.Text ''' <summary> ''' DES加密 ''' </summary> Public Class DES ''' <summary> ''' 进行DES加密 ''' </summary> ''' <param name="pToEncrypt">需要加密的字符串</param> ''' <param name="sKey">密钥</param> ''' <returns></returns> Public Function Encrypt(ByVal pToEncrypt As String, ByVal sKey As String) As String Using des As DESCryptoServiceProvider = New DESCryptoServiceProvider() Dim inputByteArray As Byte() = Encoding.UTF8.GetBytes(pToEncrypt) des.Key = Encoding.UTF8.GetBytes(sKey) des.IV = Encoding.UTF8.GetBytes("12345678") des.Padding = PaddingMode.PKCS7 des.Mode = CipherMode.ECB Dim ms As MemoryStream = New MemoryStream() Try Using cs As CryptoStream = New CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write) cs.Write(inputByteArray, 0, inputByteArray.Length) cs.FlushFinalBlock() cs.Close() End Using Dim base64 As String = Convert.ToBase64String(ms.ToArray()) Return base64 Catch ex As Exception Return "-1" Finally ms.Close() End Try End Using End Function ''' <summary> ''' 进行DES解密 ''' </summary> ''' <param name="pToDecrypt">需要解密的字符串</param> ''' <param name="sKey">密钥</param> ''' <returns></returns> Public Function Decrypt(ByVal pToDecrypt As String, ByVal sKey As String) As String Dim inputByteArray As Byte() = Convert.FromBase64String(pToDecrypt) Using des As DESCryptoServiceProvider = New DESCryptoServiceProvider() des.Key = Encoding.UTF8.GetBytes(sKey) des.IV = Encoding.UTF8.GetBytes("12345678") des.Padding = PaddingMode.PKCS7 des.Mode = CipherMode.ECB Dim ms As MemoryStream = New MemoryStream() Try Using cs As CryptoStream = New CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write) cs.Write(inputByteArray, 0, inputByteArray.Length) cs.FlushFinalBlock() cs.Close() End Using Dim str As String = Encoding.UTF8.GetString(ms.ToArray()) Return str Catch ex As Exception Return "-1" Finally ms.Close() End Try End Using End Function End Class Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim myDES As New DES Debug.Print(myDES.Decrypt("vqzlic2Xtm1pWb4GwaH0Mdh4SETUnomlkKfyxfxF2RUI4J1O4SIWcw==", "ZMCCXZQA")) End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim myDES As New DES Debug.Print(myDES.Encrypt("{""username"":""张三"",""sex"":""男""}", "ZMCCXZQA")) End Sub End Class |
可通用的C...
本文使用SqlSugarScope 单例模式,新建一个VB.NET的窗体项目,添加NuGet程序包 搜索SQLSUGAR然后在右侧点击安装,可以根据项目的.NET版本选择SQLSUGAR的版本。 在Form1中添加三个按钮,把如下程序复制进程序。 需要注意...
一、SQL Server 存储过程 原文链接 Transact-SQL中的存储过程,非常类似于Java语言中的方法,它可以重复调用。当存储过程执行一次后,可以将语句缓存中,这样下次执行的时候直接使用缓存中的语句。这样就可以提高存储过程的性能。 Ø 存储过程...
项目上有可能用到电脑间的数据传输,找了下网络资料,自己做了个程序测试一下。 可以选择作为服务器或者客户端。
有公众号之类的吗,之前这个网站打不开了
[…] 关于使用Change…
[…] 关于使用Functi…
谢谢提醒,已删 :)
还有你上边文章的图片里有一个账户名没有打…