/[winpt]/trunk/Src/wptSymEnc.cpp
ViewVC logotype

Diff of /trunk/Src/wptSymEnc.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 36 by werner, Thu Oct 27 15:25:13 2005 UTC revision 226 by twoaday, Mon Jun 12 13:40:21 2006 UTC
# Line 1  Line 1 
1  /* wptSymEnc.cpp - Symmetric encryption support  /* wptSymEnc.cpp - Symmetric encryption support
2   *      Copyright (C) 2002, 2003, 2004, 2005 Timo Schulz   *      Copyright (C) 2002-2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 23  Line 23 
23  #endif  #endif
24    
25  #include <windows.h>  #include <windows.h>
 #include <windows.h>  
26    
27  #include "wptGPG.h"  #include "wptGPG.h"
28  #include "wptCommonCtl.h"  #include "wptCommonCtl.h"
# Line 60  sym_passphrase_cb (void *hook, const cha Line 59  sym_passphrase_cb (void *hook, const cha
59    
60  /* Perform symmetric encryption on the current clipboard data.  /* Perform symmetric encryption on the current clipboard data.
61     Return 0 for success. */     Return 0 for success. */
62  int  gpgme_error_t
63  gpg_encrypt_symmetric (void)  gpg_clip_sym_encrypt (void)
64  {  {
65      gpgme_ctx_t ctx;      gpgme_ctx_t ctx;
66      gpgme_data_t plain=NULL;      gpgme_data_t plain=NULL;
# Line 70  gpg_encrypt_symmetric (void) Line 69  gpg_encrypt_symmetric (void)
69      char *pass = NULL;      char *pass = NULL;
70      int cancel = 0;      int cancel = 0;
71            
72      pass = request_passphrase2 (_("Symmetric Encryption"), 0, &cancel);      pass = request_passphrase2 (_("Symmetric Encryption"),
73                                    PASSDLG_NOTEMPTY, &cancel);
74      if (cancel)      if (cancel)
75          return 0;          return 0;
76      rc = gpgme_new (&ctx);      rc = gpgme_new (&ctx);
# Line 81  gpg_encrypt_symmetric (void) Line 81  gpg_encrypt_symmetric (void)
81          goto leave;          goto leave;
82      rc = gpgme_data_new (&ciph);      rc = gpgme_data_new (&ciph);
83      gpgme_set_armor (ctx, 1);      gpgme_set_armor (ctx, 1);
84        gpgme_set_textmode (ctx, 1);
85    
86      gpgme_set_passphrase_cb (ctx, sym_passphrase_cb, pass);      gpgme_set_passphrase_cb (ctx, sym_passphrase_cb, pass);
87    
88      rc = gpgme_op_encrypt (ctx, NULL, (gpgme_encrypt_flags_t)0, plain, ciph);          rc = gpgme_op_encrypt (ctx, NULL, (gpgme_encrypt_flags_t)0, plain, ciph);
89      if (rc)      if (rc)
90          msg_box (NULL, gpgme_strerror (rc), _("Symmetric Encryption"), MB_ERR);          msg_box (NULL, gpgme_strerror (rc), _("Symmetric Encryption"), MB_ERR);
91      else {      else {
# Line 100  leave: Line 101  leave:
101          gpgme_data_release (ciph);          gpgme_data_release (ciph);
102      gpgme_release (ctx);      gpgme_release (ctx);
103      sfree_if_alloc (pass);      sfree_if_alloc (pass);
104      return rc? WPTERR_GENERAL : 0;      return rc;
105  }  }

Legend:
Removed from v.36  
changed lines
  Added in v.226

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26