Small Basic Forum
Small Basic hash retriever - Printable Version

+- Small Basic Forum (https://litdev.uk/mybb)
+-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1)
+--- Forum: Standard Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=2)
+--- Thread: Small Basic hash retriever (/showthread.php?tid=318)



Small Basic hash retriever - sm4llprogrammer2008 - 04-20-2025

This is for the safety guaranteed for the file integrity kingdom of Windows.

ID: QQNW492.000
Link: https://smallbasic.com/program/?QQNW492.000
Requires: LitDev 1.2.30.0 Beta or higher, Small Basic 1.2 (web download version, 1.3 is UWP and doesn't support libs)

Code:
main()

Sub main
  TextWindow.Hide()
  path = LDDialogs.InputBox("Get a MD5 hash of a file. Use 'dialog' to open a file selection dialog instead.", "Hash Retriever")
  If path = "dialog" Then
    getFile = LDDialogs.OpenFile("All files (*.*)|*.*", "")
    retrievedHash = LDEncryption.MD5HashFile(getFile)
    showHash()
  Else
    retrievedHash = LDEncryption.MD5HashFile(path)
    showHash()
  EndIf
EndSub

Sub showHash
  TextWindow.Hide()
  TextWindow.Title = ""
  TextWindow.Show()
  TextWindow.WriteLine("MD5 Hash: "+retrievedHash)
  TextWindow.Write("Retrieve another hash? (Y/N) ")
  getYorN = TextWindow.Read()
  If getYorN = "y" Then
    main()
  ElseIf getYorN = "n" Then
    Program.End()
  EndIf
EndSub

Feel free to expand or to bundle in your own SB apps!