Password storage in source control

后端 未结 6 1633
独厮守ぢ
独厮守ぢ 2020-12-08 05:13

We store all our application and db passwords in plain text in source control. We do this as our build/deploy process generates required configuration files and also does a

6条回答
  •  春和景丽
    2020-12-08 06:05

    You didn't mention the language, so here is a vb.net solution we use:

    Imports System.Web.Security
    Imports System.Security.Cryptography
    Imports System.Text
    Imports Microsoft.Win32
    
    Public Class myCrypt
    
    Private myKey As String = "somekeyhere"
    Private cryptDES3 As New TripleDESCryptoServiceProvider()
    Private cryptMD5Hash As New MD5CryptoServiceProvider()
    
    
    Private Function Decrypt(ByVal myString As String) As String
        cryptDES3.Key = cryptMD5Hash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(myKey))
        cryptDES3.Mode = CipherMode.ECB
        Dim desdencrypt As ICryptoTransform = cryptDES3.CreateDecryptor()
        Dim buff() As Byte = Convert.FromBase64String(myString)
        Decrypt = ASCIIEncoding.ASCII.GetString(desdencrypt.TransformFinalBlock(buff, 0, buff.Length))
    End Function
    
    Private Function Encrypt(ByVal myString As String) As String
        cryptDES3.Key = cryptMD5Hash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(myKey))
        cryptDES3.Mode = CipherMode.ECB
        Dim desdencrypt As ICryptoTransform = cryptDES3.CreateEncryptor()
        Dim MyASCIIEncoding = New ASCIIEncoding()
        Dim buff() As Byte = ASCIIEncoding.ASCII.GetBytes(myString)
        Encrypt = Convert.ToBase64String(desdencrypt.TransformFinalBlock(buff, 0, buff.Length))
    End Function
    
    End Class
    

提交回复
热议问题