topic stringlengths 1 63 | text stringlengths 1 577k ⌀ |
|---|---|
en xbrowse como capturo el nombre del campo? | Tambien puedes intentar con esto:
[code=fw:3smt7z93]<div class="fw" id="{CB}" style="font-family: monospace;">cCampo:=oBrw:<span style="color: #000000;">SelectedCol</span>:<span style="color: #000000;">cHeader</span></div>[/code:3smt7z93] |
enable and disable a button with image | Hello,
If I have a button with only text I can Enable() or Disable(0 it. However, if i put an image on the button the enable/disable gives an error. How can i enable/disable a butoon with image?
This works:
[code=fw:lt9wffxr]<div class="fw" id="{CB}" style="font-family: monospace;"><br /> @ <span style="color: #000000;">10</span>, <span style="color: #000000;">10</span> <span style="color: #0000ff;">BUTTON</span> oBtnAanteken <span style="color: #0000ff;">PROMPT</span> <span style="color: #ff0000;">'Aantekeningen'</span> <span style="color: #0000ff;">OF</span> oDlg <span style="color: #0000ff;">ACTION</span> RK_RichNotes<span style="color: #000000;">(</span>cAanteken<span style="color: #000000;">)</span> <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">120</span>, <span style="color: #000000;">30</span><br /> oBtnAanteken:<span style="color: #000000;">Disable</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> </div>[/code:lt9wffxr]
This gives an error
[code=fw:lt9wffxr]<div class="fw" id="{CB}" style="font-family: monospace;"><br /> @ <span style="color: #000000;">10</span>, <span style="color: #000000;">10</span> <span style="color: #0000ff;">BTNBMP</span> oBtn2 <span style="color: #0000ff;">OF</span> oWndMain FILENAME <span style="color: #ff0000;">'New.png'</span>;<br /> <span style="color: #0000ff;">ACTION</span> <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span><span style="color: #ff0000;">'button click'</span><span style="color: #000000;">)</span> <span style="color: #0000ff;">SIZE</span> <span style="color: #000000;">35</span>, <span style="color: #000000;">35</span> <span style="color: #0000ff;">STYLE</span> <span style="color: #000000;">4</span> TOOLTIP <span style="color: #ff0000;">'Click me'</span><br /> oBtn2:<span style="color: #000000;">Disable</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> </div>[/code:lt9wffxr] |
enable and disable a button with image | Ok. I implement enable() and disable methods in btnbmp .
<!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->
Saludos. |
enable and disable a button with image | OK< thank you, Looking forward to it |
enabled para los btnbmp... | Hola a todos...
Quería saber como poder deshabilitar un boton... El boton lo tengo declarado como
@ 0, 32 BTNBMP oBtn2 NAME "anterior" SIZE 32, 32 of odlg action retrocede_articulos(odlg, oGetCod, oGetNom, oGetCant, oGetPrecio,oBtn2)
pero a la hora de hacerlo me da error
oBtn2:enabled()
Esto es correcto??
Saludos.
Elías Torres. |
enabled para los btnbmp... | Elías,
oBtn:Disable()
y
oBtn:Enable() |
enabled para los btnbmp... | Gracias Antonio, estaba poniendo una d al final de enable..... fuerte despiste!,jeje
Saludos, Elías Torres. |
encoding from array | I must take the numbers at n position of plinestring array
for z= 1 or 2 or 3 it run ok
for z= 4 make error ( return the wrong numbers) why ?
[code=fw:2jypq3q9]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fivewin.ch"</span><br /><br /><span style="color: #00C800;">function</span> test<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><span style="color: #00C800;">Local</span> aline<span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span><br /><span style="color: #00C800;">Local</span> nposition<span style="color: #000000;">[</span><span style="color: #000000;">5</span><span style="color: #000000;">]</span><br /><span style="color: #00C800;">Local</span> nLine<br /><span style="color: #00C800;">Local</span> nNumbers <span style="color: #000000;">[</span><span style="color: #000000;">5</span><span style="color: #000000;">]</span><br /><span style="color: #00C800;">Local</span> plinestring<span style="color: #000000;">[</span><span style="color: #000000;">4</span><span style="color: #000000;">]</span><br /><span style="color: #00C800;">local</span> z,k,n<br /><span style="color: #00C800;">local</span> nCol<br /><br />aline<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:= <span style="color: #000000;">{</span><span style="color: #000000;">1</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">6</span>,<span style="color: #000000;">7</span>,<span style="color: #000000;">1</span><span style="color: #000000;">}</span><br />aline<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:= <span style="color: #000000;">{</span><span style="color: #000000;">3</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">6</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">9</span><span style="color: #000000;">}</span><br />aline<span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span>:= <span style="color: #000000;">{</span><span style="color: #000000;">9</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">7</span>,<span style="color: #000000;">9</span><span style="color: #000000;">}</span><br /><br />plinestring<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:=<span style="color: #ff0000;">"bbbbb"</span><br />plinestring<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:=<span style="color: #ff0000;">"aaaaa"</span><br />plinestring<span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span>:=<span style="color: #ff0000;">"ccccc"</span><br />plinestring<span style="color: #000000;">[</span><span style="color: #000000;">4</span><span style="color: #000000;">]</span>:=<span style="color: #ff0000;">"abcba"</span><br /><br /><br />z:=<span style="color: #000000;">4</span><br /><br /> nposition<span style="color: #000000;">[</span><span style="color: #000000;">1</span><span style="color: #000000;">]</span>:= <span style="color: #0000ff;">substr</span><span style="color: #000000;">(</span>plinestring<span style="color: #000000;">[</span>z<span style="color: #000000;">]</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">1</span><span style="color: #000000;">)</span><br /> nposition<span style="color: #000000;">[</span><span style="color: #000000;">2</span><span style="color: #000000;">]</span>:= <span style="color: #0000ff;">substr</span><span style="color: #000000;">(</span>plinestring<span style="color: #000000;">[</span>z<span style="color: #000000;">]</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">1</span><span style="color: #000000;">)</span><br /> nposition<span style="color: #000000;">[</span><span style="color: #000000;">3</span><span style="color: #000000;">]</span>:= <span style="color: #0000ff;">substr</span><span style="color: #000000;">(</span>plinestring<span style="color: #000000;">[</span>z<span style="color: #000000;">]</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">1</span><span style="color: #000000;">)</span><br /> nposition<span style="color: #000000;">[</span><span style="color: #000000;">4</span><span style="color: #000000;">]</span>:= <span style="color: #0000ff;">substr</span><span style="color: #000000;">(</span>plinestring<span style="color: #000000;">[</span>z<span style="color: #000000;">]</span>,<span style="color: #000000;">4</span>,<span style="color: #000000;">1</span><span style="color: #000000;">)</span><br /> nposition<span style="color: #000000;">[</span><span style="color: #000000;">5</span><span style="color: #000000;">]</span>:= <span style="color: #0000ff;">substr</span><span style="color: #000000;">(</span>plinestring<span style="color: #000000;">[</span>z<span style="color: #000000;">]</span>,<span style="color: #000000;">5</span>,<span style="color: #000000;">1</span><span style="color: #000000;">)</span><br /><br /><br /> <span style="color: #B900B9;">// xbrowser nposition</span><br /><br /><span style="color: #00C800;">For</span> k= <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> <span style="color: #000000;">5</span> <span style="color: #B900B9;">// numeri</span><br /> <span style="color: #00C800;">For</span> n= <span style="color: #000000;">1</span> <span style="color: #0000ff;">to</span> <span style="color: #000000;">5</span> <span style="color: #B900B9;">//position</span><br /> nCol:= k<br /> <span style="color: #00C800;">If</span> nposition<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span>= <span style="color: #ff0000;">"a"</span><br /> nline:= <span style="color: #000000;">1</span><br /> elseif nposition<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span>= <span style="color: #ff0000;">"b"</span><br /> nline:= <span style="color: #000000;">2</span><br /> elseif nposition<span style="color: #000000;">[</span>n<span style="color: #000000;">]</span>= <span style="color: #ff0000;">"c"</span><br /> nline:= <span style="color: #000000;">3</span><br /> <span style="color: #00C800;">endif</span><br /><br /><br /><br /> nNumbers<span style="color: #000000;">[</span>k<span style="color: #000000;">]</span>:= aline<span style="color: #000000;">[</span>nline<span style="color: #000000;">]</span> <span style="color: #000000;">[</span>nCol<span style="color: #000000;">]</span><br /><br /><span style="color: #00C800;">next</span><br />nCol:= <span style="color: #000000;">0</span><br />nline:= <span style="color: #000000;">0</span><br /><span style="color: #00C800;">next</span><br /><br /><br /> xbrowser nNumbers<br /><br /> <span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span></div>[/code:2jypq3q9]
if z= 1 return 3,1,6,1,9 ok
if z= 2 return 1,3,6,7,1 ok
if z= c return 9,3,1,7,9 ok
if z= 4 return 99999 [b:2jypq3q9] bad[/b:2jypq3q9] why ? ( it must return me 11111) |
encoding from array | Silvio,
I don't see the problem you are seeing. When I run it I get 1,3,6,7,1 not 9,9,9,9,9.
James |
encoding from array | sorry ,
also 1,3,6,7,1 is bad
if the z= 4 must return me 11111 |
encoding from array | perhaps I found the error
For k= 1 to 5 // numeri
If nposition[k]= alltrim("a")
nline:= 1
elseif nposition[k]= alltrim("b")
nline:= 2
elseif nposition[k]= alltrim("c")
nline:= 3
endif
nNumbers[k]:= aline[nline][k]
next k
nopw seem to run ok |
encriptacion de archivo | Hola amigos :
Me gustaria saber si se puede encriptar y desencriptar un archivo determinado, yo tengo una aplicacion y genera unos documentos word y me gustaria saber si se pueden encriptar para que no se vea lo que es y cuando los tenga que utilizar desencriptarlos.
Un saludo
Carlos |
encriptacion de archivo | Carlos,
Puedes usar las funciones Encrypt() y Decrypt() de FiveWin
Es tan sencillo como:
MemoWrit( "nombre.ext", Encrypt( MemoRead( "reporte_original" ), "clave tuya" ) )
y luego para usarlo:
MemoWrit( "reporte_original", Decrypt( MemoRead( "nombre.ext" ), "clave tuya" ) )
lo usas y luego borras "reporte_original". |
encriptar dbf | hola foro, nuevamente por aqui, ahora quiero encriptar las dbf de mi sistema, como lo puedo hacer, no quiero que ningun software las pueda leer, unicamente por medio de mi sistema, alguna funcion, algun ejemplo?
gracias
paco |
encriptar dbf | Paco,
A parte de usar ADS para hacerlo, puedes usar las funciones Encrypt() y Decrypt() de FWH, para encriptar antes de guardar los datos. |
encriptar dbf | Gracias Antonio por tu respuesta, esto entiendo es para encriptar los datos, no es asi? mas bien lo que me interesaria seria algo asi como poder modificar la cabecera del .dbf para que no se pueda abrir, ni por dbwide, ni por adr, ni por dbf viewer,esot es por ai alguien llea a apoderarse de las dbf no las puedan leer. Esa funciones me sirven para eso?
salud2
paco |
encriptar dbf | Francisco:
ADS hace exactametne eso que tu quieres, ADS encripta tanto los datos como las cabeceras, el ARC no puede abrir los archivos encriptados, te pide la contraclave de desencriptamiento.
El truco de cambiar el primer byte de la cabecera te funciona, pero para abrir los datos desde algun editor, es eficiente pero no del todo, porque de todas formas el contenido de los archivos esta visible con cualuier editor de textos. |
encriptar dbf | como simpre buen teacher,
gracias rene
salu2
paco |
encrypt DBF using ADS Local | does he have as encrypt DBF using ADS Local for any user to access without the system to be?
Clemerson |
encrypt DBF using ADS Local | Postea el mensaje en portugues, es totalmente intenedible |
encrypt DBF using ADS Local | [quote="RF":b0kg3cri]Postea el mensaje en portugues, es totalmente intenedible[/quote:b0kg3cri]
Gostaria de encriptografar o DBF usando o ADS local, para que nenhum usuario consiga abrir usando DBU, wdbu, etc ..
Clemerson |
encrypt DBF using ADS Local | Ok, aqui va:
1) En el código fuente, deber cargar los componentes necesarios del RDDADS
[i:2atorpjc]In the source code you need to include the necesary components for the RDDADS[/i:2atorpjc]
Request ADS
RddSetDefault(ADS)
AdsSetServerType(7) //todos los servidores
AdsSetFileType(2) // archivos DBF /CDX
No olviden linkear las libs RDDADS.LIB y ACE32.LIB
[i:2atorpjc]Don´t forget to include RDDADS.LIB and ACE32.LIB libraries.[/i:2atorpjc]
2) Abrir la tabla DBF y SI NO ESTA ENCRIPTADA, establecer el password y encriptar:
[i:2atorpjc]Open the DBF and IF IT'S NOT ENCRYPTED, you must set a password and proceed to encrypt[/i:2atorpjc]
USE tabla
AdsEnableEncryption("clave") //"clave" es el password para la tabla
AdsEncryptTable()
CLOSE
3) Si la tabla ya esta encriptada entonces se abre y se establece su password:
[i:2atorpjc]If the table is already encrypted, then open it and set the password[/i:2atorpjc]
USE tabla
AdsEnableEncryption("clave")
BROWSE()
4) Se utilizan normalmente, todas las operaciones relativas a la base de datos, como SEEK, SET FILTER, APPEND, REPLACE etc. Estas realizarán la encriptacion de manera automatica. No hay necesidad de desencriptar los datos, el servidor (local o remoto), se encarga de encriptar en el momento de hacer un REPLACE y de enviar al cliente los datos desencriptados de manera automatica. Solo tienes que establecer la clave correcta para cada area.
[i:2atorpjc]Now you can use all the database related operations such SEEK, SET FILTER, APPEND, REPLACE, etc. All these instructions will perform the encryption by themselves automatically. There's no need to decrypt the data, the server (local or remote), takes care of encrypting whenever you perfom a REPLACE or when sending data to the client, the data is automatically decrypted. You just have to set the correct password for each area.[/i:2atorpjc]
5) No olvides incluir los 3 DLLs de ADS ncesarios donde esta el EXE: ACE32.DLL, AXWCS32.DLL y ADSLOC32.DLL
[i:2atorpjc]Don't forget to include the 3 needed DLLs for ADS in the sema directory where the EXE is: ACE32.DLL, AXWC32.DLL and ADSLOC32.DLL[/i:2atorpjc]
6) Cada AREA puede tener su propia llave de encriptacion, por ejemplo:
[i:2atorpjc]Each workarea can have its own encrypt password, example:[/i:2atorpjc]
USE tabla1
AdsEnableEncryption("clave1")
USE tabla2
AdsEnableEncryption("clave2")
7) No hay caida en la velocidad porque el programa no hace los procesos de encriptar/desencriptar, lo hace el server.
[i:2atorpjc]There's no decrease of the app speed, because the encrypt/decrypt process are performed by the server, not by the program.[/i:2atorpjc]
7) El proceso de encriptar con ADS ALTERA LA CABECERA DEL ARCHIVO, ni Excel ni ningun editor deDBFs podra visualizar el archivo.
<!-- s8) --><img src="{SMILIES_PATH}/icon_cool.gif" alt="8)" title="Cool" /><!-- s8) --> Datos interesantes con respecto a la encriptacion: A partir del encriptamiento de la tabla, siempre que se haga uso de ella, será necesario utilizar la función AdsEnableEncryption() con la clave de encriptamiento adecuada, para poder hacer actualizaciones al archivo, si la clave de encriptamiento no es correcta, el archivo se abre pero no se pueden leer ni modificar datos.
Cuando una tabla se encripta, también se realizan procesos de encriptamiento en la cabecera del archivo, esto se hace con el fin de que los datos no puedan ser leidos por ningún programa externo, incluyendo el ARC, el cual pedirá la clave de encriptamiento cuando se intente abrir el archivo.
El proceso de encriptar / desencriptar, pasa por el servidor ADS, los datos siempre permanecen almacenados de manera encriptada y es el servidor quien se encarga de los procesos de traducción, es decir, el servidor leerá los datos de archivo encriptado, desencripta la información y los devuelve al cliente de manera desencriptada y viceversa, en los procesos de actualización / inserción, los datos son recibidos del cliente de manera desencriptada, y cuando son escritos en el archivo de datos, el servidor encripta y guarda.
[i:2atorpjc]
Interestings facts about ADS encryption: Once encypted the table, and whenever you use it, It would be necesary to use the AdsEnableEncryption() function with the correct encryption password in order to perform update operations on the DBF, if the password is not correct the table is open but you cannot read, nor update the data.
When a table is encrypted, the header of the DBF is also encrypted, this is perform to avoid any external program to open the DBF, including the ARC (The DBU for advantage tables) which will ask for the password when you try to open it.
The encrypt/decrypt process goes through the ADS server, the data is always stored in an encrypted way, and is the server which performs the translation process, this means that the server will read the data in the encrypted file, will decrypt it and will be send decrypted to the client application and viceversa, in the append/update process the data is recieved from the client application decrypted and it's encrypted and saved to the file by the server.[/i:2atorpjc] |
encrypt DBF using ADS Local | Muito Obrigado ... |
encrypt DBF using ADS Local | René;
Como siempre --muy buena información.
Muy agradecido.
De paso, si esto funciona tan y tan bien, que razón pudiera existir para no usar encryption con ADS?
Recibe un saludo muy coridal,
Reinaldo. |
encrypt DBF using ADS Local | Reinaldo:
[quote="reinaldocrespo":dmfbouhi]
De paso, si esto funciona tan y tan bien, que razón pudiera existir para no usar encryption con ADS?
[/quote:dmfbouhi]
1) Esta caracteristica esta disponible en el servidor local, sin embargo ten en cuenta que con el server local solo pueden utilizar 5 usuarios en red la aplicacion sin tener problema de velocidad. Con el servidor local yo no meteria mi mano al fuego para mas de 5 usuarios en temas de velocidad.
2) el unico problema que hemos visto con respecto a la encriptacion, es el tamaño de las tablas cuando las quieres meter en un ZIP, veras, si tu compactas en un archivo ZIP un DBF comun y corriente, puedes obtener grados de compresion superiores al 50%, ¿ porque ?, pues porque dentro del archivo DBF hay muchisimos espacios en blanco que son facilmente comprimibles por el algoritmo del ZIP, por ejemplo, si tienes un campo que guarda un nombre y ese campo mide 60 caracteres, y en promedio utilizas 40, tienes 20 espacios en blanco que puden ser facilmente comprimibles. Cuando tienes la tabla encriptada, esto no sucede asi, ADS utiliza un algoritmo de encirptamiento que nunca proporciona el mismo caracter encriptado para los mismos caracteres, por ejemplo, si yo tengo el dato:
RF
ADS te presentara criptado algo como esto:
[rkL-*Qc,;
En un algoritmo tradicional de encriptamiento, todas las letras tienen un mismo signo encriptado, por ejemplo la "r" en este caso equivale a la "E", pero con ADS eso no funciona asi, porque el encriptamiento se da POR POSICION, asi que la misma letra "E" puede tener distintos signos que la identifiquen dependiendo en la posicion donde este. Volviendo a este ejemplo, si tenemos un campo de longitud 40 para almacenar el dato, y solo estas guardando "RF", estan libres 29 espacios en blanco, sin embargo, ADS TAMBIEN ENCRIPTA LOS ESPACIOS EN BLANCO, y como cada espacio en blanco tiene una posicion distinta, el algoritmo genera caracteres distintos que luego el ZIP no puede comprimir.
Esa seria la unica desventaja de usar la encriptacion de ADS. |
encrypt() ? | Hola amigos
Estoy intentado guardar en un archivo ini, una cadena encriptada el problema esta en que no me guarda la cadena
clave:=encrypt("12345")
Msginfo(clave) // Aqui me lo muestra perfectamente
Pero si lo guardo en un ini me muestra un valor distinto al que me muestra en el msginfo
alguna idea ?
un saludo y gracias desde ya |
encrypt() ? | Guardalo en un fichero con MEMOWRIT(".\Fichero.dat",clave).
Recuperalo con clave := MEMOREAD(".\Fichero")
[u:168vl43q]Otra solución [/u:168vl43q]sería convertir cada caracter en un string de su valor ASCII. Por ejemplo:
cDat := ""
FOR nCont = 1 TO LEN(clave)
cDat += STRZERO(ASC(SUBSTR(CLAVE,nCont,1)),3)
NEXT
Cada caracter de 'clave' se a convertido en un alfanumérico de tres dígitos tipo "069" ó "128"
Ahora guarda cDat en el INI.
Para recuperarlo, Carga cDat desde el INI y:
clave := ""
FOR nCont = 1 TO LEN(cDat) STEP 3
clave += CHR(VAL(SUBSTR(cDat,nCont,3)))
NEXT
No lo he probado, lo mismo hay algún BUG pero esa es la idea, o algo así.
Un saludo. |
encrypt() ? | Gracias Manuramos me funciona perfecto |
encrypt-decrypt word doc | Hello,
I am preparing for the GDPR.
So I try to encrypt and decrypt a word file.
But I get an error if I try to reopen the decypted word file.
Could someone please help me.
Best regards,
Otto
[code=fw:34brnnsd]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #B900B9;">// New FiveWin Encrypt() and Decrypt() functions</span><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"FiveWin.ch"</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">function</span> Main<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> cText := <span style="color: #ff0000;">""</span><br /> <span style="color: #00C800;">local</span> cTextDecryp := <span style="color: #ff0000;">""</span><br /> <span style="color: #00C800;">local</span> cLetter := <span style="color: #ff0000;">"c:<span style="color: #000000;">\f</span>wh<span style="color: #000000;">\s</span>amples<span style="color: #000000;">\I</span>nfoCardDemo.docx"</span><br /> <span style="color: #00C800;">local</span> cTextenc := <span style="color: #ff0000;">""</span><br /> <span style="color: #00C800;">local</span> cDSt := <span style="color: #ff0000;">"c:<span style="color: #000000;">\f</span>wh<span style="color: #000000;">\s</span>amples<span style="color: #000000;">\I</span>nfoCardDemo.enc"</span><br /> <span style="color: #00C800;">local</span> cLetterNew := <span style="color: #ff0000;">"c:<span style="color: #000000;">\f</span>wh<span style="color: #000000;">\s</span>amples<span style="color: #000000;">\I</span>nfoCardDemoNew.docx"</span><br /> *----------------------------------------------------------<br /><br /> cText := memoread<span style="color: #000000;">(</span> cLetter <span style="color: #000000;">)</span><br /><br /> cTextenc := Encrypt<span style="color: #000000;">(</span> cText, <span style="color: #ff0000;">"User1Key"</span> <span style="color: #000000;">)</span> <br /> memowrit<span style="color: #000000;">(</span> cDSt, cTextenc <span style="color: #000000;">)</span><br /> ? <span style="color: #ff0000;">"Doc-Datei verschlüsselt"</span><br /> <br /> cText := memoread<span style="color: #000000;">(</span> cDSt <span style="color: #000000;">)</span><br /> cTextDecryp = Decrypt<span style="color: #000000;">(</span> cText , <span style="color: #ff0000;">"User1Key"</span> <span style="color: #000000;">)</span> <br /> memowrit<span style="color: #000000;">(</span> cLetterNew, cTextDecryp <span style="color: #000000;">)</span><br /> ? <span style="color: #ff0000;">"Doc-Datei entschlüsselt"</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span></div>[/code:34brnnsd] |
encrypt-decrypt word doc | I did something like encrypt part of the file docx. But I used fOpen/fWrite |
encrypt-decrypt word doc | Otto,
Do you use a SQL-database?
Then you store the DOC-file in a BLOB-field. The SQL-database is already password-protected. |
encrypt-decrypt word doc | Hello Natter,
thank you. Fopen and fwrite is working fine.
Hello Mark, thank you. I do not use SQL.
Best regards,
Otto
[code=fw:2sd5s8qa]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #B900B9;">// Encrypt() and Decrypt() functions DOCX </span><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"FiveWin.ch"</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">function</span> Main<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> cLetter := <span style="color: #ff0000;">"c:<span style="color: #000000;">\f</span>wh<span style="color: #000000;">\s</span>amples<span style="color: #000000;">\I</span>nfoCardDemo.docx"</span><br /> <span style="color: #00C800;">local</span> cDocenc := <span style="color: #ff0000;">"c:<span style="color: #000000;">\f</span>wh<span style="color: #000000;">\s</span>amples<span style="color: #000000;">\I</span>nfoCardDemo.enc"</span><br /> <span style="color: #00C800;">local</span> cLetterNew := <span style="color: #ff0000;">"c:<span style="color: #000000;">\f</span>wh<span style="color: #000000;">\s</span>amples<span style="color: #000000;">\I</span>nfoCardDemoNew.docx"</span><br /> *----------------------------------------------------------<br /> <br /> Encryptraw<span style="color: #000000;">(</span> cLetter, cDocenc <span style="color: #000000;">)</span> <br /> ? <span style="color: #ff0000;">"Doc-Datei verschlüsselt"</span><br /> <br /> Decryptraw<span style="color: #000000;">(</span> cDocenc, cLetterNew <span style="color: #000000;">)</span><br /> ? <span style="color: #ff0000;">"Doc-Datei entschlüsselt"</span><br /> <br /><span style="color: #00C800;">return</span> <span style="color: #00C800;">nil</span><br /> <br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">FUNCTION</span> Decryptraw<span style="color: #000000;">(</span> cSrc, cDst <span style="color: #000000;">)</span> <span style="color: #B900B9;">//extended from filecopyraw by NagesWaraRao</span><br /><br /> <span style="color: #00C800;">local</span> hSrc, hDst, nBytes<br /> <span style="color: #00C800;">local</span> nBuf := <span style="color: #000000;">64000</span><br /> <span style="color: #00C800;">local</span> cBuf := Space<span style="color: #000000;">(</span> nBuf <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">local</span> lCopied := .f.<br /> <span style="color: #00C800;">local</span> cTextenc := <span style="color: #ff0000;">""</span><br /> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> hSrc := FOpen<span style="color: #000000;">(</span> cSrc, <span style="color: #000000;">64</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span> >= <span style="color: #000000;">0</span><br /> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> hDst := FCreate<span style="color: #000000;">(</span> cDst, <span style="color: #000000;">0</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span> >= <span style="color: #000000;">0</span><br /> <span style="color: #00C800;">do</span> <span style="color: #00C800;">while</span> .t.<br /> nBytes := FRead<span style="color: #000000;">(</span> hSrc, @cBuf, nBuf <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">if</span> nBytes > <span style="color: #000000;">0</span><br /> cTextenc := Decrypt<span style="color: #000000;">(</span> cBuf, <span style="color: #ff0000;">"User1Key"</span> <span style="color: #000000;">)</span> <br /> FWrite<span style="color: #000000;">(</span> hDst, cTextenc, nBytes <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">if</span> nBytes < nBuf<br /> lCopied := .t.<br /> exit<br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">enddo</span><br /> fClose<span style="color: #000000;">(</span> hDst <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> fClose<span style="color: #000000;">(</span> hSrc <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /><br /><span style="color: #00C800;">return</span> lCopied<br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #00C800;">FUNCTION</span> Encryptraw<span style="color: #000000;">(</span> cSrc, cDst <span style="color: #000000;">)</span> <br /><br /> <span style="color: #00C800;">local</span> hSrc, hDst, nBytes<br /> <span style="color: #00C800;">local</span> nBuf := <span style="color: #000000;">64000</span><br /> <span style="color: #00C800;">local</span> cBuf := Space<span style="color: #000000;">(</span> nBuf <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">local</span> lCopied := .f.<br /> <span style="color: #00C800;">local</span> cTextenc := <span style="color: #ff0000;">""</span><br /> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> hSrc := FOpen<span style="color: #000000;">(</span> cSrc, <span style="color: #000000;">64</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span> >= <span style="color: #000000;">0</span><br /> <span style="color: #00C800;">if</span> <span style="color: #000000;">(</span> hDst := FCreate<span style="color: #000000;">(</span> cDst, <span style="color: #000000;">0</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span> >= <span style="color: #000000;">0</span><br /> <span style="color: #00C800;">do</span> <span style="color: #00C800;">while</span> .t.<br /> nBytes := FRead<span style="color: #000000;">(</span> hSrc, @cBuf, nBuf <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">if</span> nBytes > <span style="color: #000000;">0</span><br /> cTextenc := Encrypt<span style="color: #000000;">(</span> cBuf, <span style="color: #ff0000;">"User1Key"</span> <span style="color: #000000;">)</span> <br /> FWrite<span style="color: #000000;">(</span> hDst, cTextenc, nBytes <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">if</span> nBytes < nBuf<br /> lCopied := .t.<br /> exit<br /> <span style="color: #00C800;">endif</span><br /> <span style="color: #00C800;">enddo</span><br /> fClose<span style="color: #000000;">(</span> hDst <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /> fClose<span style="color: #000000;">(</span> hSrc <span style="color: #000000;">)</span><br /> <span style="color: #00C800;">endif</span><br /><br /><span style="color: #00C800;">return</span> lCopied<br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><br /><br /><br /><br /> </div>[/code:2sd5s8qa] |
encrypt/decrypt in Harbour and php | Hi,
Are there a set of functions that, for example, I encrypt the string in the php web page, and I read and decrypt in Habour -prg code?
Thank you |
encrypt/decrypt in Harbour and php | Pues no es exactamente encriptar... pero para ocultar un poco el contenido puedes usar la codificación en base64.
Encode y decode en xharbour
[code=fw:qkqv7xhf]<div class="fw" id="{CB}" style="font-family: monospace;"><br />cBas64 := hb_base64encode<span style="color: #000000;">(</span>::<span style="color: #000000;">user</span>+<span style="color: #ff0000;">":"</span>+::<span style="color: #000000;">pass</span>,len<span style="color: #000000;">(</span>::<span style="color: #000000;">user</span>+<span style="color: #ff0000;">":"</span>+::<span style="color: #000000;">pass</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span> <br />cString := hb_base64decode<span style="color: #000000;">(</span>::<span style="color: #000000;">respuesta</span><span style="color: #000000;">[</span><span style="color: #ff0000;">"qrdata"</span><span style="color: #000000;">]</span><span style="color: #000000;">)</span><br /> </div>[/code:qkqv7xhf]
en PHP
[code=fw:qkqv7xhf]<div class="fw" id="{CB}" style="font-family: monospace;"><br />$str = <span style="color: #ff0000;">'This is an encoded string'</span>;<br />echo base64_encode<span style="color: #000000;">(</span>$str<span style="color: #000000;">)</span>;<br /><br /><?php<br />$str = <span style="color: #ff0000;">'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='</span>;<br />echo base64_decode<span style="color: #000000;">(</span>$str<span style="color: #000000;">)</span>;<br />?><br /> </div>[/code:qkqv7xhf]
En este momento me encuentro investigando y avanzando de a poco sobre el tema de encriptar con los comandos openssl apenas tenga resultados comento. |
encrypt/decrypt in Harbour and php | [quote="leandro":t45qyinq]
En este momento me encuentro investigando y avanzando de a poco sobre el tema de encriptar con los comandos openssl apenas tenga resultados comento.[/quote:t45qyinq]
Leandro, What openssl functions are you using?
Moises, use functions hb_base64Encode and hb_base64Decode |
encrypt/decrypt in Harbour and php | Cristobal como siempre gracias por responder, en este momento me encuentro leyendo sobre el tema de openssl, es nuevo para mi. Pero a lo que quiero llegar, es a traducir este codigo de php a xharbour "si se puede".
[code=fw:gupcsu3j]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #B900B9;">//Configuración del algoritmo de encriptación</span><br /><span style="color: #B900B9;">//Debes cambiar esta cadena, debe ser larga y unica</span><br /><span style="color: #B900B9;">//nadie mas debe conocerla</span><br />$clave = <span style="color: #ff0000;">'Una cadena, muy, muy larga para mejorar la encriptacion'</span>;<br /><span style="color: #B900B9;">//Metodo de encriptación</span><br />$method = <span style="color: #ff0000;">'aes-256-cbc'</span>;<br /><span style="color: #B900B9;">// Puedes generar una diferente usando la funcion $getIV()</span><br />$iv = base64_decode<span style="color: #000000;">(</span><span style="color: #ff0000;">"C9fBxl1EWtYTL1/M8jfstw=="</span><span style="color: #000000;">)</span>;<br /> <span style="color: #B900B9;">/*<br /> Encripta el contenido de la variable, enviada como parámetro.<br /> */</span><br /> $encriptar = <span style="color: #00C800;">function</span> <span style="color: #000000;">(</span>$valor<span style="color: #000000;">)</span> use <span style="color: #000000;">(</span>$method, $clave, $iv<span style="color: #000000;">)</span> <span style="color: #000000;">{</span><br /> <span style="color: #00C800;">return</span> openssl_encrypt <span style="color: #000000;">(</span>$valor, $method, $clave, <span style="color: #00C800;">false</span>, $iv<span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span>;<br /> <span style="color: #B900B9;">/*<br /> Desencripta el texto recibido<br /> */</span><br /> $desencriptar = <span style="color: #00C800;">function</span> <span style="color: #000000;">(</span>$valor<span style="color: #000000;">)</span> use <span style="color: #000000;">(</span>$method, $clave, $iv<span style="color: #000000;">)</span> <span style="color: #000000;">{</span><br /> $encrypted_data = base64_decode<span style="color: #000000;">(</span>$valor<span style="color: #000000;">)</span>;<br /> <span style="color: #00C800;">return</span> openssl_decrypt<span style="color: #000000;">(</span>$valor, $method, $clave, <span style="color: #00C800;">false</span>, $iv<span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span>;<br /> <span style="color: #B900B9;">/*<br /> Genera un valor para IV<br /> */</span><br /> $getIV = <span style="color: #00C800;">function</span> <span style="color: #000000;">(</span><span style="color: #000000;">)</span> use <span style="color: #000000;">(</span>$method<span style="color: #000000;">)</span> <span style="color: #000000;">{</span><br /> <span style="color: #00C800;">return</span> base64_encode<span style="color: #000000;">(</span>openssl_random_pseudo_bytes<span style="color: #000000;">(</span>openssl_cipher_iv_length<span style="color: #000000;">(</span>$method<span style="color: #000000;">)</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;<br /> <span style="color: #000000;">}</span>;<br /> ?><br /> <br /> <br /> <?php<br /> <br /><span style="color: #B900B9;">/**<br /> * function to encrypt<br /> * @param string $data<br /> * @param string $key<br /> */</span><br /><span style="color: #00C800;">function</span> encrypt<span style="color: #000000;">(</span>$data,$key<span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br /> $iv = openssl_random_pseudo_bytes<span style="color: #000000;">(</span>openssl_cipher_iv_length<span style="color: #000000;">(</span><span style="color: #ff0000;">'aes-256-cbc'</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;<br /> $encrypted=openssl_encrypt<span style="color: #000000;">(</span>$data, <span style="color: #ff0000;">"aes-256-cbc"</span>, $key, <span style="color: #000000;">0</span>, $iv<span style="color: #000000;">)</span>;<br /> <span style="color: #B900B9;">// return the encrypted string with $iv joined </span><br /> <span style="color: #00C800;">return</span> base64_encode<span style="color: #000000;">(</span>$encrypted.<span style="color: #ff0000;">"::"</span>.$iv<span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</span><br /> <br /><span style="color: #B900B9;">/**<br /> * function to decrypt<br /> * @param string $data<br /> * @param string $key<br /> */</span><br /><span style="color: #00C800;">function</span> decrypt<span style="color: #000000;">(</span>$data,$key<span style="color: #000000;">)</span><br /><span style="color: #000000;">{</span><br /> list<span style="color: #000000;">(</span>$encrypted_data, $iv<span style="color: #000000;">)</span> = explode<span style="color: #000000;">(</span><span style="color: #ff0000;">'::'</span>, base64_decode<span style="color: #000000;">(</span>$data<span style="color: #000000;">)</span>, <span style="color: #000000;">2</span><span style="color: #000000;">)</span>;<br /> <span style="color: #00C800;">return</span> openssl_decrypt<span style="color: #000000;">(</span>$encrypted_data, <span style="color: #ff0000;">'aes-256-cbc'</span>, $key, <span style="color: #000000;">0</span>, $iv<span style="color: #000000;">)</span>;<br /><span style="color: #000000;">}</span><br /> <br /> <br />$key=<span style="color: #ff0000;">"1235@"</span>;<br />$string=<span style="color: #ff0000;">"la casa azul"</span>;<br /> <br />$encryptado=encrypt<span style="color: #000000;">(</span>$string,$key<span style="color: #000000;">)</span>;<br />echo $encryptado;<br />echo <span style="color: #ff0000;">"<hr>"</span>;<br />echo decrypt<span style="color: #000000;">(</span>$encryptado,$key<span style="color: #000000;">)</span>;<br /> </div>[/code:gupcsu3j] |
encrypt/decrypt in Harbour and php | Muchas gracias.
¿No existe un método de encriptacion más fuerte? |
encrypt/decrypt in Harbour and php | [quote="MOISES":1uz7sryr]Muchas gracias.
¿No existe un método de encriptacion más fuerte?[/quote:1uz7sryr]
Look for the hb_Crypt and hb_Decrypt functions, and you can even support yourself for using these functions in the cMimeEnc and cMimeDec functions
Pd: in this forum, please use the English language. Thank you
Busca las funciones hb_Crypt y hb_Decrypt, e incluso puedes apoyarte para el uso de estas funciones en las funciones cMimeEnc y cMimeDec
Pd: en este forum, por favor, usad el idioma inglés. Gracias |
encrypt/decrypt in Harbour and php | Thank you Cristóbal.
Do you refer to this?
<!-- m --><a class="postlink" href="https://github.com/vszakats/hb/blob/master/contrib/xhb/hbcrypt.c">https://github.com/vszakats/hb/blob/mas ... /hbcrypt.c</a><!-- m --> |
encrypt/decrypt in Harbour and php | Yes, but in version 3.2 there are also
I use this functions with cMimeEnc and cMimeDec functions |
encrypting dbf files | Is there a fivewin function that encrypts dbf files by closing or interupting the fivewin program so that they can not be modified with an external program |
encrypting dbf files | You can use FWH functions Encrypt() and Decrypt() so all info inside the DBF is encrypted.
field->myfield := Encrypt( "value", cPassword ) |
encrypting dbf files | Note that when using Encrypt/Decrypt all fields must be character format. |
encrypting dbf files | Using tables with no memo field I manage them in this way
[code=fw:1k7luhle]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fivewin.ch"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"Dbinfo.ch"</span><br /><br /><span style="color: #00C800;">FUNCTION</span> MAIN<br /><br /><span style="color: #0000ff;">SELECT</span> <span style="color: #000000;">0</span><br />USE t090<br /><br />DBINFO<span style="color: #000000;">(</span> DBI_PASSWORD, <span style="color: #ff0000;">"12345678"</span> <span style="color: #000000;">)</span><br /><br />browse<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /><br /> </div>[/code:1k7luhle]
I create a dbf encrypted in this way
[code=fw:1k7luhle]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"DbStruct.ch"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"Dbinfo.ch"</span><br /><br /><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span> cFileIn, cFileOut, cCodice <span style="color: #000000;">)</span><br /><span style="color: #00C800;">LOCAL</span> aStruct := <span style="color: #000000;">{</span><span style="color: #000000;">}</span><br /><br /> <span style="color: #B900B9;">// open file to read to obtain structure</span><br /> USE &<span style="color: #000000;">(</span>cFileIn<span style="color: #000000;">)</span> <span style="color: #0000ff;">ALIAS</span> filein<br /> aStruct := DBSTRUCT<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /> USE<br /><br /> <span style="color: #B900B9;">// create encrypted file </span><br /> DBCREATE<span style="color: #000000;">(</span> cFileOut, aStruct <span style="color: #000000;">)</span><br /> USE &<span style="color: #000000;">(</span>cFileOut<span style="color: #000000;">)</span> <span style="color: #0000ff;">ALIAS</span> fileout<br /><br /> DBINFO<span style="color: #000000;">(</span> DBI_PASSWORD, cCodice <span style="color: #000000;">)</span> <span style="color: #B900B9;">// cCodice = "12345678" in example</span><br /><br /> APPEND <span style="color: #0000ff;">FROM</span> &<span style="color: #000000;">(</span>cFileIn<span style="color: #000000;">)</span><br /><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /><br /> </div>[/code:1k7luhle] |
encrypting dbf files | What includes are necessary to use encrypt() and decrypt() files please |
encrypting dbf files | Jds:
(x)Harbour supports three functions to handle encryption / decryption transparently:
1. Sx_DBFencrypt (cPassword) - encrypts all records in database file.
2. Sx_DBFdecrypt () - decrypts all records in database file.
3. Sx_SetPass (cPassword) - set / changes password to be used in the encryption functions.
With the above mentioned suggestions the database fields remains as you designed them (Date, Numerics, Memos, etc.).
The drawback with the Encrypt() and Decrypt() functions is that, as James pointed out correctly, all fields must be character.
Hope this helps. |
encrypting dbf files | So, if I understood it well, the user has to use a password to encrypt;
So it is not possible that by exiting the program all dbf files can be encrypted so that the user can not modify the dbf files with an external program |
encrypting dbf files | JDS,
[quote:ka2ehfyz]So, if I understood it well, the user has to use a password to encrypt;[/quote:ka2ehfyz]
Of course, it would not be secure if anyone can run the program without logging in. So each authorized user needs to login using a password. The actual password that encrypts/decrypts the databases is the same for all users. It can also be encrypted and stored in an external file. No users need to know what this password is. The admin should be able to change it periodically.
[quote:ka2ehfyz]So it is not possible that by exiting the program all dbf files can be encrypted so that the user can not modify the dbf files with an external program[/quote:ka2ehfyz]
In the above system, the databases are encrypted all the time. The data is only decrypted when in RAM.
I can't see encrypting the databases after the last user exits--this would be slow, impractical, and not secure. The databases would all have to be decrypted and written back to disk while any user was using the program. During this time anyone could copy all the databases (decrypted) to another place. Also, after encrypting the databases all the decrypted copies would have to be securely erased. This system would not be secure at all.
Regards,
James |
encrypting dbf files | Jds:
Steps on using encryption:
1. You encrypt all tables with a tool that uses the Sx_DBFencrypt (cPassword) function.
2. Your program has the password either hard coded or in an external dbf.
3. Make SURE if you hard coded it to not set it up as a literal, build it as a result of some sort of mathematical function.
4. This way it cannot be retrieved via a binary editor since the compiler cannot "resolve" or pre-process it at compile time.
5. This way DBF are ALWAYS ENCRYPTED.
Hope this helps. I've been using encryption since the old Clipper 5.2e/DOS days (SIx driver). |
encrypting dbf files | Hunter,
[quote:1ix0mupz]1. You encrypt all tables with a tool that uses the Sx_DBFencrypt (cPassword) function.[/quote:1ix0mupz]
I assume this is an EXE? Where does one get the EXE or source?
It seems you could also write your own--just open each dbf, read each record, encrypt it and save. Seems simple enough.
Regards,
James |
encrypting dbf files | James:
You just write a simple program to encrypt tables.
[code=fw:2qcepgfv]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"Common.ch"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"FiveWin.ch"</span><br /><br />PROCEDURE Main <span style="color: #000000;">(</span>cFileName, cPassWord<span style="color: #000000;">)</span><br /><br /><br /> <span style="color: #00C800;">DEFAULT</span> cFileName <span style="color: #0000ff;">TO</span> <span style="color: #ff0000;">""</span><br /> <span style="color: #00C800;">DEFAULT</span> cPassword <span style="color: #0000ff;">TO</span> <span style="color: #ff0000;">""</span><br /><br /> <span style="color: #00C800;">IF</span> ! EMPTY<span style="color: #000000;">(</span>cPassword<span style="color: #000000;">)</span><br /> <span style="color: #00C800;">IF</span> FILE<span style="color: #000000;">(</span>cFileName<span style="color: #000000;">)</span><br /> USE <span style="color: #000000;">(</span>cFileName<span style="color: #000000;">)</span> VIA <span style="color: #ff0000;">"DBFCDX"</span> EXCLUSIVE<br /> Sx_DBFencrypt <span style="color: #000000;">(</span>cPassword<span style="color: #000000;">)</span><br /> USE<br /> <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span><span style="color: #ff0000;">"File: "</span> + cFileName + <span style="color: #ff0000;">" Encrypted"</span><span style="color: #000000;">)</span><br /> <span style="color: #00C800;">ELSE</span><br /> <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span><span style="color: #ff0000;">"File: "</span> + cFileName + <span style="color: #ff0000;">" NOT Found"</span><span style="color: #000000;">)</span><br /> <span style="color: #00C800;">ELSE</span><br /> <span style="color: #0000ff;">MsgInfo</span> <span style="color: #000000;">(</span><span style="color: #ff0000;">"Empty Passwords Not Allowed"</span><span style="color: #000000;">)</span><br /> <span style="color: #00C800;">ENDIF</span><br /><span style="color: #00C800;">RETURN</span> <br /> </div>[/code:2qcepgfv] |
encrypting dbf files | Is it possible to encrypt only some fields of a table .
For example, in a People dbf file, i only want to Encrypt Name and Adress .
Thanks |
encrypting dbf files | Jack,
[quote:2v2po7np]i only want to Encrypt Name and Adress[/quote:2v2po7np]
Why?
Why not just encrypt everything? There is very little speed penalty. If security is an issue, why secure only some of the data?
Regards,
James |
encrypting dbf files | Hunter,
Thanks for the example code.
Do you have any ideas on how we could check to see if a file is already encrypted? I just thought it might be handy to prevent ever encrypting a file twice.
James |
encrypting dbf files | I use the free ADS encryption. It encrypts the entire file. |
encrypting dbf files | Jeff,
[quote:398wswrw]I use the free ADS encryption. It encrypts the entire file.[/quote:398wswrw]
So does the Six RDD. I was responding to Jack's request to just encrypt a couple of fields. I don't know if the Six RDD will do this, but I don't know why it would be useful either.
James |
encrypting dbf files | Hunter,
I just reread this:
[quote:wg96ir43](x)Harbour supports three functions to handle encryption / decryption transparently:
1. Sx_DBFencrypt (cPassword) - encrypts all records in database file.
2. Sx_DBFdecrypt () - decrypts all records in database file.[/quote:wg96ir43]
This leaves me wondering, are there functions to encrypt and decrypt a record (or field)? I can't see how decrypting an entire DBF would be practical in an application.
Are the SX functions documented somewhere online, or is there a downloadable manual?
What would be really nice is just something like SET ENCRYPTION ON, then using the database as you normally would. Is this possible? Or, better yet, if the Six RDD could automatically detect if the file was encrypted, and then automatically (and transparently) encrypt and decrypt the data as needed. Now that would that be nice!
However, if we had the capability to encrypt and decrypt records, then we could build the encryption/decryption into a database class so it would all be transparent.
James |
encrypting dbf files | Most of the SX functions are documented in the SIX3.NG. It´s a 500kb file. I have it but I´m not sure it´s allowed to publicly share it. If yes I can upload it to my FTP server, if not I can send as email attachment. Just let me know. |
encrypting dbf files | James,
[quote="James Bott":3s9vyavn]What would be really nice is just something like SET ENCRYPTION ON, then using the database as you normally would. Is this possible? Or, better yet, if the Six RDD could automatically detect if the file was encrypted, and then automatically (and transparently) encrypt and decrypt the data as needed. Now that would that be nice![/quote:3s9vyavn]
Please have a look at Marco's message at the start of this thread. <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) -->
EMG |
encrypting dbf files | Enrico,
[quote:yevxkyph]Please have a look at Marco's message at the start of this thread.[/quote:yevxkyph]
Hmm, I guess you are telling me, no there are no record or field level decryption Six functions?
As I mentioned, it seems impractical to decrypt all DBFs when running a program. When it the program is multi-user, it gets a lot more complicated as the files need only to be decrypted when the first user runs the program. If the DBFs are large then it could take 10 minutes or more to decrypt the files. You would have to move all DBFs across the network twice--once to read and once to write.
Then when the last user exited the program all the files would then have to encrypted again and all the decrypted files would have to be securely erased. This would take even longer than opening the program.
While all the files are decrypted, they are vulnerable to unsecure access. Anyone could open the files and copy them.
Record or field level decryption seems to be the only feasible method of working with encrypted databases. So, I guess the Six driver is out and FW's own encrypt/decrypt functions are in. Since FW's functions only work with character fields, then we need to keep track of fieldtypes in a datadictionary file so we can convert the character data to the proper fieldtype on-the-fly.
Ah, the kingdom for SET ENCRYPTION ON.
Regards,
James |
encrypting dbf files | James,
I think you have not read Marco's message carefully. Please do it. <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) -->
EMG |
encrypting dbf files | James, Enrico:
The Sx_DBFencrypt & Sx_DBFdecrypt functions are used in a separate program, as the one I posted earlier in this post's thread. Afterwards you just open your DBF files and call the Sx_SetPass (cPassWord) function. The SIx driver handles everything transparently, meaning that you DON'T have to decrypt / encrypt any record at all before / after processing. It's done all automatically. As Antonio posted in one of my posts, all drivers (DBFCDX, DBFNTX) on Harbour supports these functions.
As to how to find out if a DBF is encrypted, you can use the Sx_TableType() and it will return a. 1 - for non encrypted b. 2 - encrypted. You can also encrypt the file a couple of times, just make sure you decrypt it in reverse order.
This function encrypts the whole record without the need to set all field types as character ones. It is not possible to encrypt just a couple of fields only. As James pointed out, it will be useless, better to encrypt all data fields.
Hope this clarifies a couple of questions. |
encrypting dbf files | HunterEC,
I'm trying the following sample:
[code=fw:634slry8]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> USE MYTABLE EXCLUSIVE<br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span><br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> INKEY<span style="color: #000000;">(</span> <span style="color: #000000;">0</span> <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span></div>[/code:634slry8]
It prints: .F. and 1. What am I missing?
EMG |
encrypting dbf files | Hi.
By simply changing to ADS rdd, you get to use their encryption functions on free .dbf tables as well as data dictionary bound tables -- and it is all very well documented on the help file.
Reinaldo. |
encrypting dbf files | Enrico:
For encryption / decryption via the Sx_DBFencrypt() and Sx_DBFdecrypt() you have to open the DBF with the SIX driver. Afterwards you can keep using the DBFCDX or DBFNTX one. This is due to the fact that these function changes one byte at the DBF header that the Sx_TableType() inspects (first byte). That is the reason that I use a separate tool for encrypting / decrypting DBFs.
[code=fw:vl08dddc]<div class="fw" id="{CB}" style="font-family: monospace;"> <span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> USE MYTABLE EXCLUSIVE VIA <span style="color: #ff0000;">"SIX"</span> <--- AFTER THIS SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span> WILL <span style="color: #00C800;">RETURN</span> A <span style="color: #000000;">2</span><br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span><br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> INKEY<span style="color: #000000;">(</span> <span style="color: #000000;">0</span> <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span></div>[/code:vl08dddc] |
encrypting dbf files | HunterEC,
[quote="HunterEC":2upo5dl9]For encryption / decryption via the Sx_DBFencrypt() and Sx_DBFdecrypt() you have to open the DBF with the SIX driver.[/quote:2upo5dl9]
Sorry, no changes I'm still missing something... <!-- s:-( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":-(" title="Sad" /><!-- s:-( -->
[code=fw:2upo5dl9]<div class="fw" id="{CB}" style="font-family: monospace;">REQUEST SIXCDX<br /><br /><br /><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> USE POLIZZE EXCLUSIVE VIA <span style="color: #ff0000;">"SIXCDX"</span><br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span><br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> INKEY<span style="color: #000000;">(</span> <span style="color: #000000;">0</span> <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span></div>[/code:2upo5dl9]
EMG |
encrypting dbf files | I also tried this but no lack:
[code=fw:3b6t9t4f]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"Hbsix.ch"</span><br /><br /><br />REQUEST SIXCDX<br /><br /><br /><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> USE POLIZZE EXCLUSIVE VIA <span style="color: #ff0000;">"SIXCDX"</span><br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span><br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> INKEY<span style="color: #000000;">(</span> <span style="color: #000000;">0</span> <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span></div>[/code:3b6t9t4f]
EMG |
encrypting dbf files | Hunter,
OK, I got SIX encryption working. Decrypting on the fly. I love it! This is going to be really useful.
Do you know what form of encryption is being used? I'm sure my customer's are going to want to know.
Regards,
James |
encrypting dbf files | Enrico,
It seems to be really transparent. You don't even need the REQUEST or the VIA.
Are you sure you are starting with an unencrypted file?
James |
encrypting dbf files | James,
[quote="James Bott":e8rfkxyk]Are you sure you are starting with an unencrypted file?[/quote:e8rfkxyk]
Of course. <!-- s:-( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":-(" title="Sad" /><!-- s:-( -->
EMG |
encrypting dbf files | James,
are you using latest xHarbour from SVN? Can I see your linker configuration file?
EMG |
encrypting dbf files | Hunter,
Another question.
Do you know if the SIX driver automatically securely erases the original unencrypted DBF after it encrypts the file? Or, maybe it is encrypted in place (there is no new encrypted copy made)?
James |
encrypting dbf files | Enrico,
[quote:1dza1mzu]are you using latest xHarbour from SVN? Can I see your linker configuration file?[/quote:1dza1mzu]
I am using FWH 13.04 with xHarbour 1.2.3 Intl. (SimpLex) (Build 20130326). I don't know if xHarbour is the latest version.
Also using Borland 5.82.
ilink.cfg contains just this:
-L"c:\bcc582\lib"
I am using buildx.bat to build the test files.
Regards,
James |
encrypting dbf files | Enrico,
Are you closing the file after encryption, then reopening it? I don't see that happening in your posted code. Maybe that is the issue.
James |
encrypting dbf files | James,
[quote="James Bott":kvhbltei]Enrico,
Are you closing the file after encryption, then reopening it? I don't see that happening in your posted code. Maybe that is the issue.
James[/quote:kvhbltei]
Tried. No changes. My current sample is:
[code=fw:kvhbltei]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> USE POLIZZE EXCLUSIVE<br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span><br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> INKEY<span style="color: #000000;">(</span> <span style="color: #000000;">0</span> <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span></div>[/code:kvhbltei]
I don't get the table POLIZZE.DBF encrypted. Can I see the sample you're using?
EMG |
encrypting dbf files | Enrico,
This is working for me.
[code=fw:2n1z4mev]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fivewin.ch"</span><br /><br /><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">local</span> cPassword:=<span style="color: #ff0000;">"EHAB"</span><br /><br /> USE xcustomer EXCLUSIVE <span style="color: #B900B9;">// unencrypted source</span><br /><br /> copy <span style="color: #0000ff;">to</span> customer<br /> use<br /> use customer <span style="color: #B900B9;">// unencrptyed test file</span><br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> cPassword <span style="color: #000000;">)</span><br /><br /> <span style="color: #B900B9;">// you must close and then reopen the file</span><br /> use<br /> use customer<br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> <span style="color: #0000ff;">msgInfo</span><span style="color: #000000;">(</span>company,<span style="color: #ff0000;">"Company - encrypted"</span><span style="color: #000000;">)</span><br /><br /> Sx_SetPass<span style="color: #000000;">(</span>cPassword<span style="color: #000000;">)</span><br /><br /> <span style="color: #0000ff;">msgInfo</span><span style="color: #000000;">(</span>company,<span style="color: #ff0000;">"Company - decrypted"</span><span style="color: #000000;">)</span><br /><br /> use<br /><br /> <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span></div>[/code:2n1z4mev] |
encrypting dbf files | James,
I found the culprit: it doesn't work with memo fields. <!-- s:-( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":-(" title="Sad" /><!-- s:-( -->
Can you confirm this?
EMG |
encrypting dbf files | I'm very interested in this thread. However, we have some other considerations.
Many of us are now working with Harbour / MSVC 2012. Antonio has been encouraging people to move up to the newer compilers. The functions you are testing and working with are only valid with xHarbour.
James, you are using the old command style for testing these files, but how well will this work with data objects ?
Regarding ADS. That's a good option for those people who use the ADS Server. However, in my tests, I'm seeing much better performance on a network ( peer to peer ) when using DBFCDX instead of the ADS Local server. I have both available, so I technically could use the ADS option ( I think ), but then I may get performance hits from people using LOCAL.
I would appreciate if you would consider these issues as you discuss the options. I, also, am finding a need to encrypt my data. With all the "integration" I find people accessing my databases without caution. When they crash the databases, they tell the client its all my fault and I should repair them. It makes for rough situations.
Tim |
encrypting dbf files | Tim,
I see no reason it wouldn't work with data objects. We just need to subclass and add the password unlock and possibly a check to make sure the database is encrypted.
When time permits, I will test this to be certain.
James |
encrypting dbf files | James,
did you check if the encrypting function works with memo fields? Maybe you missed my message above.
EMG |
encrypting dbf files | Enrico,
[quote:2tnrek9k]did you check if the encrypting function works with memo fields?[/quote:2tnrek9k]
I will try to get to it today.
James |
encrypting dbf files | James:
I don't know the encryption algorithm that it uses. It encrypts the records over the old ones, no copy is made. Undelete tools will not recover the unencrypted data.
Enrico:
It does work with memo fields since I've been using it since 1996 in my production apps.
I suggest that you compile a small program that do the initial encryption using the SIX driver and then, and only then, the DBF header will have the 1st byte changed. Afterwards you can use the DBFCDX driver.
If you wish to email me one of your files, I'll happily will try your code with your DBFs. |
encrypting dbf files | HunterEC,
[quote="HunterEC":piea84q2]Enrico:
It does work with memo fields since I've been using it since 1996 in my production apps.[/quote:piea84q2]
Great! <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) -->
[quote="HunterEC":piea84q2]I suggest that you compile a small program that do the initial encryption using the SIX driver and then, and only then, the DBF header will have the 1st byte changed. Afterwards you can use the DBFCDX driver.[/quote:piea84q2]
This is my [b:piea84q2]non-working[/b:piea84q2] sample. Please fix it. Use any tables with memo fields and xHarbour. Thank you! <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) -->
[code=fw:piea84q2]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> USE ANYTABLE EXCLUSIVE<br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span><br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> INKEY<span style="color: #000000;">(</span> <span style="color: #000000;">0</span> <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span></div>[/code:piea84q2]
EMG |
encrypting dbf files | Hunter,
The following code is working fine for me [b:11xs3pyx]without[/b:11xs3pyx] using the SIX RDD. I can confirm that the file is encrypted.
When I attempt to use either VIA SIXCDX or EXTERNAL SIXCDX I get this error:
Error: Unresolved external '_HB_FUN_SIXCDX' referenced
Any ideas? Do we really need this? Is there an include file that I am supposed to be referencing? Do you have a sample program you can share?
James
[code=fw:11xs3pyx]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #B900B9;">// Test Six lib's DBF encryption</span><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"fivewin.ch"</span><br /><br /><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> use xcustomer exclusive <span style="color: #B900B9;">// source file</span><br /> copy <span style="color: #0000ff;">to</span> customer <span style="color: #B900B9;">// working file</span><br /> use<br /><br /> USE customer EXCLUSIVE<br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span> <span style="color: #B900B9;">// returns .t.</span><br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #B900B9;">// returns 2</span><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /> </div>[/code:11xs3pyx] |
encrypting dbf files | James,
[quote="James Bott":38ho6jov]The following code is working fine for me [b:38ho6jov]without[/b:38ho6jov] using the SIX RDD.[/quote:38ho6jov]
As far as I know, SIXCDX is included in xHarbour's DBFCDX.
EMG |
encrypting dbf files | Enrico,
[quote:3guovg90]As far as I know, SIXCDX is included in xHarbour's DBFCDX.[/quote:3guovg90]
That was the conclusion that I came to. Probably Hunter has not tried it recently and thus his statement that you have to use the Six driver to encrypt.
James |
encrypting dbf files | James,
[quote="James Bott":clpbpbso]Enrico,
[quote:clpbpbso]As far as I know, SIXCDX is included in xHarbour's DBFCDX.[/quote:clpbpbso]
That was the conclusion that I came to. Probably Hunter has not tried it recently and thus his statement that you have to use the Six driver to encrypt.
James[/quote:clpbpbso]
I agree. Anyway, I would like to know how to get it to work with memo fields too...
EMG |
encrypting dbf files | Enrico,
I am unable to encrypt memo files too.
Hunter,
Are you perhaps using the original SIX library instead of the xHarbour one?
Maybe memo field encryption has not yet been implemented in the xHarbour version.
James |
encrypting dbf files | Six Driver NG Guide online
[url:s7wk4116]http://www.ousob.com/ng/six3/index.php[/url:s7wk4116]
From the section on SX_encrypt() (Note that this encrypts a string and is not the same as SX_dbfencrypt() but we can probably assume that this uses the same encryption method).
[url:s7wk4116]http://www.ousob.com/ng/six3/ng25e56.php[/url:s7wk4116]
[quote:s7wk4116]------------
Description: Sx_Encrypt() and it related function Sx_Decrypt() provide
an easy way to integrate data security to a system. The
encryption engine provides security through the use of a
64-bit (8 byte) security code and multi-adaptive computa-
tion. Multi-adaptive computation ensures a wide uniqueness
within the outputted encrypted string. If a string of all
blanks were encrypted you would see a wide distribution of
characters. This ensures a reasonable amount of security
at a small speed penalty.
Of course, the best way to protect your data is to keep it
away from those who shouldn't have access to it. Protect
your passwords, and don't store them in .DBF files.
This encryption/decryption method is _not_ DES (Data
Encryption Standard) compliant, so it can be used in
programs distributed both in the US and Overseas.[/quote:s7wk4116]
OK, 64bit encryption is not very good, but it will prevent casual users from getting into the DBFs. It would be nice to have the option of higher level encryption but there would also be a speed penalty.
James |
encrypting dbf files | More on encrypted memo fields:
This SIX driver apparently doesn't work with memo files. However, I think we can come up with a workaround. You will need to do something like the following.
1) Create a DBF without a memo field (this can be encrypted using SX_DBFENCRYPT(). There needs to be a primary-key field containing a unique non-blank value. Use the primary key field to link to another DBF containing only a memo field.
2) Create a subclass of TDatabase (or TData) and write new save() and load() methods. In these methods you need to automatically lookup the memo field associated with the original primary-key. Then encrypt or decypt the memo field data as needed.
The above will make everything transparent and automatic.
James |
encrypting dbf files | Regarding my previous message, you will also need to add new Append() and Delete() methods. These will need to add and delete records from both files.
James |
encrypting dbf files | James, Enrico:
I do encrypt my DBFs with a 16 bit Clipper utility program using the SIX driver. Memos do encrypt. In 32 bit you can encrypt the memo field before storing it with the Sx_encrypt (cPassword) function and that's it (in case that the memo fields does not get encrypted). |
encrypting dbf files | Hunter,
[quote="HunterEC":13xwa04a]James, Enrico:
I do encrypt my DBFs with a 16 bit Clipper utility program using the SIX driver. Memos do encrypt. In 32 bit you can encrypt the memo field before storing it with the Sx_encrypt (cPassword) function and that's it (in case that the memo fields does not get encrypted).[/quote:13xwa04a]
Sorry, I didn't get it working... <!-- s:-( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":-(" title="Sad" /><!-- s:-( -->
EMG |
encrypting dbf files | Enrico:
If you can email me (morenoec2007 at hotmail dot com) your program or a sample program and your DBFs, I'll give it a try. Thank you. |
encrypting dbf files | Hunter,
[quote="HunterEC":3q6i0h19]Enrico:
If you can email me (morenoec2007 at hotmail dot com) your program or a sample program and your DBFs, I'll give it a try. Thank you.[/quote:3q6i0h19]
Here it is:
[code=fw:3q6i0h19]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> DBCREATE<span style="color: #000000;">(</span> <span style="color: #ff0000;">"MYTEST"</span>, <span style="color: #000000;">{</span> <span style="color: #000000;">{</span> <span style="color: #ff0000;">"TEST1"</span>, <span style="color: #ff0000;">"C"</span>, <span style="color: #000000;">35</span>, <span style="color: #000000;">0</span> <span style="color: #000000;">}</span>,;<br /> <span style="color: #000000;">{</span> <span style="color: #ff0000;">"TEST2"</span>, <span style="color: #ff0000;">"M"</span>, <span style="color: #000000;">10</span>, <span style="color: #000000;">0</span> <span style="color: #000000;">}</span> <span style="color: #000000;">}</span> <span style="color: #000000;">)</span><br /><br /> USE MYTEST EXCLUSIVE<br /><br /> APPEND BLANK<br /><br /> REPLACE FIELD -> test1 WITH <span style="color: #ff0000;">"Test1"</span><br /> REPLACE FIELD -> test2 WITH <span style="color: #ff0000;">"Test2"</span><br /><br /> CLOSE<br /><br /> USE MYTEST EXCLUSIVE<br /><br /> ? SX_DBFENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span><br /><br /> ? SX_ENCRYPT<span style="color: #000000;">(</span> <span style="color: #ff0000;">"EMAG"</span> <span style="color: #000000;">)</span><br /><br /> ? SX_TABLETYPE<span style="color: #000000;">(</span><span style="color: #000000;">)</span><br /><br /> CLOSE<br /><br /> INKEY<span style="color: #000000;">(</span> <span style="color: #000000;">0</span> <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span></div>[/code:3q6i0h19]
EMG |
encrypting dbf files | Hunter,
[quote:h6xnumh9]I do encrypt my DBFs with a 16 bit Clipper utility program using the SIX driver. Memos do encrypt. In 32 bit you can encrypt the memo field before storing it with the Sx_encrypt (cPassword) function and that's it (in case that the memo fields does not get encrypted).[/quote:h6xnumh9]
I am not sure I understand what you are saying. Are you confirming that 32bit FWH programs cannot encrypt DBF files containing a memo field?
Yes, you can encrypt a memo field using SX_encrypt() however you cannot cannot create the typical DBF with a memo field as the entire DBF cannot be encrypted. So as I mentioned in previous messages, you have to create the main DBF WITHOUT a memo field and another DBF containing only the memo field and do the linking via code and encrypting/decrypting using Sx_encrypt() and Sx_decrypt() which considerably complicates things.
Do you know why memo field encryption was never implemented in 32bits?
Regards,
James |
encrypting dbf files | James,
[quote="James Bott":3va4fnuv]Do you know why memo field encryption was never implemented in 32bits?[/quote:3va4fnuv]
It was a Przemek decision. <!-- s:-( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":-(" title="Sad" /><!-- s:-( -->
EMG |
encrypting dbf files | Enrico,
[quote:1setswcn]It was a Przemek decision.[/quote:1setswcn]
I wonder why. It seems that it would be simple to implement since the encryption/decryption code is already working. Maybe there is some other technical issue...
Maybe some user requests would get him motivated.
James |
encrypting dbf files | To All
There functions have served me well over the years .. I copied this ( public domain ) code from an old Clipper Tools book some time ago and have modified it from time to time.
As you can see .. I added msginfo() to test the values and rem'd them out. Feel free to try them for yourselves. Please note that this code offsets the data by one character at the beginning and you may need to adjust the width of your variables.
Rick Lipkin
[code=fw:3jzzvv7q]<div class="fw" id="{CB}" style="font-family: monospace;"><br /><span style="color: #B900B9;">//------------------------</span><br />Func ENCRYPT<span style="color: #000000;">(</span> TO_DO <span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">Local</span> PadBack,Done,Qaz<br /><br />PadBack := Len<span style="color: #000000;">(</span>To_Do<span style="color: #000000;">)</span><br />*<span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"Padback"</span> <span style="color: #000000;">)</span><br />*<span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> PadBack <span style="color: #000000;">)</span><br />Done := <span style="color: #ff0000;">" "</span><br /><br />TO_DO := ALLTRIM<span style="color: #000000;">(</span>TO_DO<span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">FOR</span> QAZ := LEN<span style="color: #000000;">(</span>TO_DO<span style="color: #000000;">)</span> <span style="color: #0000ff;">to</span> <span style="color: #000000;">1</span> STEP <span style="color: #000000;">-1</span><br /> DONE := DONE + CHR<span style="color: #000000;">(</span><span style="color: #0000ff;">ASC</span><span style="color: #000000;">(</span><span style="color: #0000ff;">SUBSTR</span><span style="color: #000000;">(</span>TO_DO, QAZ, <span style="color: #000000;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span> + <span style="color: #000000;">104</span><span style="color: #000000;">)</span><br /><span style="color: #00C800;">NEXT</span><br /><br />*<span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"In Encrypt"</span> <span style="color: #000000;">)</span><br />*<span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span> Done <span style="color: #000000;">)</span><br />*<span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> Len<span style="color: #000000;">(</span> Done <span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">RETURN</span><span style="color: #000000;">(</span> Fill_Out<span style="color: #000000;">(</span> Done, PadBack <span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br /><span style="color: #B900B9;">//--------------------</span><br />Func DENCRYPT<span style="color: #000000;">(</span> TO_DO <span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">LOCAL</span> PADBACK := LEN<span style="color: #000000;">(</span>TO_DO<span style="color: #000000;">)</span>, DONE := <span style="color: #ff0000;">" "</span>, QAZ<br />TO_DO := ALLTRIM<span style="color: #000000;">(</span>TO_DO<span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">FOR</span> QAZ := LEN<span style="color: #000000;">(</span>TO_DO<span style="color: #000000;">)</span> <span style="color: #0000ff;">to</span> <span style="color: #000000;">1</span> STEP <span style="color: #000000;">-1</span><br /> DONE := DONE + CHR<span style="color: #000000;">(</span><span style="color: #0000ff;">ASC</span><span style="color: #000000;">(</span><span style="color: #0000ff;">SUBSTR</span><span style="color: #000000;">(</span>TO_DO, QAZ, <span style="color: #000000;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span> - <span style="color: #000000;">104</span><span style="color: #000000;">)</span><br /><span style="color: #00C800;">NEXT</span><br /><br /><span style="color: #00C800;">RETURN</span><span style="color: #000000;">(</span> FILL_OUT<span style="color: #000000;">(</span>DONE, PADBACK<span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br /><span style="color: #B900B9;">//----------------------</span><br />Func FILL_OUT<span style="color: #000000;">(</span> Done, PadBack <span style="color: #000000;">)</span><br /><br />* <span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"In Fill_Out Pcount"</span><span style="color: #000000;">)</span><br />* <span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> pcount<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br />* <span style="color: #0000ff;">Msginfo</span><span style="color: #000000;">(</span> len<span style="color: #000000;">(</span> done <span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">IF</span> PCOUNT<span style="color: #000000;">(</span><span style="color: #000000;">)</span> = <span style="color: #000000;">1</span><br /> PadBack := <span style="color: #000000;">80</span><br /><span style="color: #00C800;">ELSE</span><br /><br />* <span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"Initial PadBack"</span> <span style="color: #000000;">)</span><br />* <span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> PadBack <span style="color: #000000;">)</span><br /><br /> <span style="color: #00C800;">IF</span> TYPE<span style="color: #000000;">(</span><span style="color: #ff0000;">"PadBack"</span><span style="color: #000000;">)</span> = <span style="color: #ff0000;">"C"</span><br /> PadBack := VAL<span style="color: #000000;">(</span>PadBack<span style="color: #000000;">)</span><br /> <span style="color: #00C800;">ENDIF</span><br /><br /> * PadBack := IIF<span style="color: #000000;">(</span>PadBack <= <span style="color: #000000;">1</span>, <span style="color: #000000;">80</span>, PadBack<span style="color: #000000;">)</span><br /> <span style="color: #00C800;">If</span> PadBack >= <span style="color: #000000;">1</span><br /> <span style="color: #00C800;">Else</span><br /> PadBack := <span style="color: #000000;">80</span><br /> <span style="color: #00C800;">Endif</span><br /><br /> * PadBack := IIF<span style="color: #000000;">(</span>PadBack < <span style="color: #000000;">1</span>, <span style="color: #000000;">80</span>, PadBack<span style="color: #000000;">)</span><br />* <span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"End PadBack"</span><span style="color: #000000;">)</span><br />* <span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> PadBack <span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">ENDIF</span><br /><br />*<span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"if PadBack <= len(Done)"</span><span style="color: #000000;">)</span><br />*<span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> PadBack<span style="color: #000000;">)</span><br />*<span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> len<span style="color: #000000;">(</span>Done<span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br /><span style="color: #00C800;">IF</span> PadBack <= LEN<span style="color: #000000;">(</span>Done<span style="color: #000000;">)</span><br />* <span style="color: #0000ff;">Msginfo</span><span style="color: #000000;">(</span> <span style="color: #ff0000;">"Return Done"</span><span style="color: #000000;">)</span><br />* <span style="color: #0000ff;">Msginfo</span><span style="color: #000000;">(</span> Done <span style="color: #000000;">)</span><br />* <span style="color: #0000ff;">msginfo</span><span style="color: #000000;">(</span> len<span style="color: #000000;">(</span>done <span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /> <span style="color: #00C800;">RETURN</span><span style="color: #000000;">(</span>Done<span style="color: #000000;">)</span><br /><span style="color: #00C800;">ENDIF</span><br /><br /><span style="color: #00C800;">RETURN</span><span style="color: #000000;">(</span>Done + SPACE<span style="color: #000000;">(</span>PadBack - LEN<span style="color: #000000;">(</span>Done<span style="color: #000000;">)</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span><br /><br /><br /> </div>[/code:3jzzvv7q] |
encrypting dbf files | Rick,
[quote="Rick Lipkin":u1ny12rf]To All
There functions have served me well over the years .. I copied this ( public domain ) code from an old Clipper Tools book some time ago and have modified it from time to time.[/quote:u1ny12rf]
Thank you. We are discussing an encrypting system at RDD level here. It already exists but unfortunately it doesn't work with memo fields.
EMG |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.