Portal    Foro    Buscar    FAQ    Registrarse    Conectarse


Publicar nuevo tema  Responder al tema 
Página 1 de 1
 
 
Clase Txtasc, Que Opinan?
Autor Mensaje
Responder citando   Descargar mensaje 
Mensaje Clase Txtasc, Que Opinan? 
 
buenas

tuve que ingeniarme para sacar los hashes de un archivo .txt.asc por eso esta clase.
que opinan ustedes, es un buen planteo? es pésimo? no esta bien construida la clase?
que mejoras le harían?

espero sus comentarios....

' gambas class file

'Clase txtasc by postapase 28/12/2016

Public Const SHA1 As String = "SHA1"
Public Const SHA256 As String = "SHA256"
Public Const SHA512 As String = "SHA512"
Public Const FALLO As String = "FALLO"


Private Const COMIENZO As String = "-----BEGIN PGP SIGNED MESSAGE-----"
Private Const HASH As String = "Hash:"
Private Const FINAL As String = "-----BEGIN PGP SIGNATURE-----"

Property TipoHash As String
Property HashDistro As Collection

Private $TipoHash As String
Private $HashDistro As New Collection


Public Sub _new(RutaArchivo As String) ''Ingresar ruta de archivo *.txt.asc
  Dim archivo As File
  Dim parrafo As String
  Dim tipo As String
  Dim CorteTipoHash As New String[]
  Dim CorteHash As New String[]
  Dim Contenido As String
  Dim integridad As Byte = 1
  
  
  If Not Exist(RutaArchivo) Then
    Debug Error.Text
    Return
  Endif
  
  archivo = Open RutaArchivo For Read
  
  While Not Eof(archivo)
  
    Line Input #archivo, parrafo
          
    Print "parrafo=" & parrafo      
      
    Select Case integridad
      Case 1
        If InStr(parrafo, COMIENZO) = 0 Then
          Debug "integridad de archivo dañada(Linea 47- If InStr(parrafo, COMIENZO) = 0"
          TipoHash_Write(FALLO)
          Return
       Endif
      Case 2
        If InStr(parrafo, HASH) = 0 Then
          Debug "integridad de archivo dañada (Linea 53-If InStr(parrafo, HASH) = 0)"
          TipoHash_Write(FALLO)
          Return
        Endif
    End Select
    
    If InStr(parrafo, FINAL) <> 0 Then Break
    
    If InStr(parrafo, HASH) <> 0 Then
    
      CorteTipoHash = Split(parrafo, " ", Null, True)
    
      QueTipoDeHashEs(Trim(CorteTipoHash[1]))
  
    Endif
    
    If InStr(parrafo, COMIENZO) = 0 And If InStr(parrafo, HASH) = 0 And If Not IsNull(parrafo) Then
      
      CorteHash = Split(parrafo, " ", Null, True)
      
      If CorteHash.Count <> 2 Or If CorteHash.Count = 0 Then
        Continue
        $HashDistro.Add(Trim(CorteHash[0]), Trim(CorteHash[1]))
      Endif
    
      
    Endif
    
   Inc integridad
  
   Wend
  
  Close #archivo
  
  HashDistro_Write($HashDistro)
  
End

Private Function TipoHash_Read() As String
  Return $TipoHash
End

Private Sub TipoHash_Write(Value As String)
  $TipoHash = Value
End

Private Function HashDistro_Read() As Collection
  Return $HashDistro
End

Private Sub HashDistro_Write(Value As Collection)
  $HashDistro = Value
End

Private Sub QueTipoDeHashEs(texto As String)
  
   Select Case texto
    Case SHA1
      $TipoHash = SHA1
    Case SHA256
      $TipoHash = SHA256
    Case SHA512
      $TipoHash = SHA512
    Case Else
      $TipoHash = ""
  End Select
  
  TipoHash_Write($TipoHash)
  
End
 

 




===================
Software libre, programación libre, vida libre es la Public function Libertad()as Invendible
Proyectos: VisorRV1960,Taller2015,Tanteador
https://sourceforge.net/u/v3ctor-full/profile/
Blog: http://novatocodegambas.blogspot.com.uy/
 
v3ctor - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Mostrar mensajes anteriores:    
 
OcultarTemas parecidos
Tema Autor Foro Respuestas último mensaje
No hay nuevos mensajes Ejemplo De Clase Publica Y Clase Privada Shell Aplicaciones/Fragmentos de Código 2 Martes, 28 May 2013, 11:41 Ver último mensaje
shordi
No hay nuevos mensajes ¿ Es La Clase Padre Una Clase Abstracta ? Shell General 3 Viernes, 04 Julio 2014, 08:58 Ver último mensaje
jsbsan
No hay nuevos mensajes Clase Audio Y Clase Configuracion De Audio... v3ctor Aplicaciones/Fragmentos de Código 3 Jueves, 08 Octobre 2015, 08:35 Ver último mensaje
jsbsan
No hay nuevos mensajes ¿Que Opinan Del Logo Que Hice Para Gambas? NestorG General 13 Martes, 20 Febrero 2018, 20:21 Ver último mensaje
jsbsan
 

Publicar nuevo tema  Responder al tema  Página 1 de 1
 

Usuarios navegando en este tema: 0 registrados, 0 ocultos y 1 invitado
Usuarios registrados conectados: Ninguno


 
Lista de permisos
No puede crear mensajes
No puede responder temas
No puede editar sus mensajes
No puede borrar sus mensajes
No puede votar en encuestas
No puede adjuntar archivos
Puede descargar archivos
No puede publicar eventos en el calendario



  

 

cron