I have spent a lot of time downloading and trying to use various VB6 examples
to obtain the mean and covariance of YCbCr of jpg image files folder c:\test, however, I only get this code in Csharp only. How I can get it work in VB 6.0?
int num_samples = 0;
foreach (string f in Directory.GetFiles(txtTrainingFolder.Text, "*.jpg"))
{
using (Bitmap bmp = new Bitmap(f))
Add(bmp);
num_samples++;
}
public void Add(Bitmap bmp)
{
for (int y = 0; y < bmp.Height; y++)
for (int x = 0; x < bmp.Width; x++)
{
Color c = bmp.GetPixel(x, y);
// Skip black pixels in training images
if (c.R < 10 && c.G < 10 && c.B < 10)
continue;
double cb, cr;
CbCr(c.R, c.G, c.B, out cb, out cr);
sum_cr += cr;
sum_cb += cb;
sum_rr += cr * cr;
sum_rb += cr * cb;
sum_bb += cb * cb;
n++;
}
}
public void Finish()
{
// Mean
mean_cr = sum_cr / n;
mean_cb = sum_cb / n;
// Covariance
cov00 = sum_bb / n - mean_cb * mean_cb;
cov01 = sum_rb / n - mean_cr * mean_cb;
cov11 = sum_rr / n - mean_cr * mean_cr;
// Inverse covariance
double det = cov00 * cov11 - cov01 * cov01;
inv00 = cov00 / det;
inv01 = -cov01 / det;
inv11 = cov11 / det;
}
static void CbCr(byte r, byte g, byte b, out double cb, out double cr)
{
double d0 = r / 255.0, d1 = g / 255.0, d2 = b / 255.0;
cb = (-(0.148 * r) - (0.291 * g) + (0.439 * b) + 128);
cr = ((0.439 * r) - (0.368 * g) - (0.071 * b) + 128);
//cb = -37.797 * d0 - 74.203 * d1 + 112 * d2 + 128;
//cr = 112 * d0 - 93.786 * d1 - 18.214 * d2 + 128;
}
Try the project below:
when you click on the picturebox it then finds all jpg files in a directory and process them
'1 form with
' 1 picturebox: name=Picture1
Option Explicit
Private Sub Form_Resize()
Picture1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Private Sub Picture1_Click()
ProcessFiles "c:\temp\", "*.jpg"
End Sub
Private Sub ProcessFiles(strPath As String, strMask As String)
Dim strFile As String
strFile = Dir$(strPath & strMask)
Do Until Len(strFile) = 0
'ShowFile strPath & strFile
LoadFile strPath & strFile
strFile = Dir$() 'find next file
Loop
End Sub
Private Sub ShowFile(strFile As String)
Caption = strFile
Picture1.Picture = LoadPicture(strFile)
End Sub
Private Sub LoadFile(strFile As String)
Dim intFile As Integer
Dim bytArray() As Byte
intFile = FreeFile
Open strFile For Binary As #intFile
bytArray = Input(LOF(intFile), #intFile)
Close #intFile
End Sub
ShowFile will show the file in the picturebox
LoadFile will load the file into an array of bytes
There are several online code C# to VB converters available. However, you will still need to do the VB.NET to VB6 conversion manually. The .NET and VB6 libraries are completely different and there are also many differences in the language features (e.g. the Using statement used in your code does not exist in VB6. It unloads the bitmap).
Converters:
developerFusion
DOTNET Spider
SharpDevelop code converter
Telerik code converter
Related
As introduced in this work (code), the following code sould refine an image (i.e. a gray scale saliency map).
Refinement Function:
function sal = Refinement(y, dim)
th_2 = graythresh(y);
if dim == 1
sal = y;
sal(y<th_2) = 10*(y(y < th_2))/th_2 - 10;
sal(y>=th_2) = 10*(y(y >= th_2) - th_2)/(1-th_2);
sal = 1 ./ (1 + exp(-sal)) + y;
sal = normalization(sal, 0);
elseif dim == 2
[r, c] = size(y);
y_col = reshape(y,[1 r*c]);
sal_col = y_col;
sal_col(y_col<th_2) = 10*(y_col(y_col < th_2))/th_2 - 10;
sal_col(y_col>=th_2) = 10*(y_col(y_col >= th_2) - th_2)/(1-th_2);
sal_col = 1 ./ (1 + exp(-sal_col)) + y_col;
sal = reshape(sal_col, [r c]);
end
end
normalization function:
function matrix = normalization(mat, flag)
% INPUT :
% flag: 1 denotes that the mat is a 3-d matrix;
% 0 denotes that the mat is a matrix;
%
if flag ~= 0
dim = size(mat,3);
matrix = mat;
for i = 1:dim
matrix(:,:,i) = ( mat(:,:,i) - min(min(mat(:,:,i)))) / ( max(max(mat(:,:,i))) - min(min( mat(:,:,i))) + eps);
end
else
matrix = ( mat - min(min(mat)))/( max(max(mat)) - min(min(mat)) + eps);
end
However, after applying the function values of the image matrix will be changed, the result remains the same as the image before the refinement.
Is there a conceptual error with that or the implementation failed?
P.S. The input image (saliency map) for refinery is something like below. in the refined saliency map, the foreground (satrfish in this image) should stand out(becomes homogeneously white as possible) and the background noise should be removed (becomes homogenously black as possible):
I am using following code to convert BMP Image to GRF format.
Public Shared Function CreateGrf(filename As String, imagename As String) As String
Dim bmp As Bitmap = Nothing
Dim imgData As BitmapData = Nothing
Dim pixels As Byte()
Dim x As Integer, y As Integer, width As Integer
Dim sb As StringBuilder
Dim ptr As IntPtr
Try
bmp = New Bitmap(filename)
imgData = bmp.LockBits(New System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat)
width = (bmp.Width + 7) \ 8
pixels = New Byte(width - 1) {}
sb = New StringBuilder(width * bmp.Height * 2)
sb.Append(Environment.NewLine)
ptr = imgData.Scan0
For y = 0 To bmp.Height - 1
Marshal.Copy(ptr, pixels, 0, width)
For x = 0 To width - 1
sb.AppendFormat("{0:X2}", CByte(Not pixels(x)))
Next
sb.Append(Environment.NewLine)
ptr = ptr.ToInt64() + imgData.Stride
Next
Finally
If bmp IsNot Nothing Then
If imgData IsNot Nothing Then
bmp.UnlockBits(imgData)
End If
bmp.Dispose()
End If
End Try
Return [String].Format("~DG{0},{1},{2},", imagename, width * y, width) + sb.ToString()
End Function
However there is an extra vertical line drawn at the end of the converted GRF file even though there is no such line in the BMP file. Other than that the size and everything is Ok. It seems the last pixel (hex value) of each row is not correct in the GRF file.
Original BMP File.
Converted GRF FIle
Public Function ConvertBmp2Grf(fileName As String, imageName As String) As Boolean
Dim TI As String
Dim i As Short
Dim WID As Object
Dim high As Object
Dim TEM As Short, BMPL As Short, EFG As Short, n2 As String, LON As String
Dim header_name As String, a As String, j As Short, COUN As Short, BASE1 As Short
Dim L As String, TOT As String
Dim N As Object
Dim TOT1 As Integer
Dim LL As Byte
FileOpen(1, fileName, OpenMode.Binary, , , 1) ' OPEN BMP FILE TO READ
FileGet(1, LL, 1)
TI = Convert.ToString(Chr(LL))
FileGet(1, LL, 2)
TI += Convert.ToString(Chr(LL))
If TI <> "BM" Then
FileClose()
Return False
End If
i = 17
FileGet(1, LL, i + 1)
N = LL * 256
FileGet(1, LL, i)
N = (N + LL) * 256
FileGet(1, LL, i + 3)
N = (N + LL) * 256
FileGet(1, LL, i + 2)
N += LL
WID = N
i = 21
FileGet(1, LL, i + 1)
N = LL * 256
FileGet(1, LL, i)
N = (N + LL) * 256
FileGet(1, LL, i + 3)
N = (N + LL) * 256
FileGet(1, LL, i + 2)
N += LL
high = N
FileGet(1, LL, 27)
N = LL
FileGet(1, LL, 29)
If N <> 1 Or LL <> 1 Then
'BMP has too many colors, only support monochrome images
FileClose(1)
Return False
End If
TEM = Int(WID / 8)
If (WID Mod 8) <> 0 Then
TEM += 1
End If
BMPL = TEM
If (BMPL Mod 4) <> 0 Then
BMPL += (4 - (BMPL Mod 4))
EFG = 1
End If
n2 = fileName.Substring(0, fileName.LastIndexOf("\", StringComparison.Ordinal) + 1) + imageName + ".GRF"
FileOpen(2, n2, OpenMode.Output) 'OPEN GRF TO OUTPUT
TOT1 = TEM * high : TOT = Mid(Str(TOT1), 2)
If Len(TOT) < 5 Then
TOT = Strings.Left("00000", 5 - Len(TOT)) + TOT
End If
LON = Mid(Str(TEM), 2)
If Len(LON) < 3 Then
LON = Strings.Left("000", 3 - Len(LON)) + LON
End If
header_name = imageName
PrintLine(2, "~DG" & header_name & "," & TOT & "," & LON & ",")
For i = high To 1 Step -1
a = ""
For j = 1 To TEM
COUN = 62 + (i - 1) * BMPL + j
FileGet(1, LL, COUN)
L = LL
If j = TEM And (EFG = 1 Or (WID Mod 8) <> 0) Then
BASE1 = 2 ^ ((TEM * 8 - WID) Mod 8)
L = Int(L / BASE1) * BASE1 + BASE1 - 1
End If
L = Not L
a += Right(Hex(L), 2)
Next j
PrintLine(2, a)
Next i
FileClose()
Return True
End Function
Marshal.Copy(ptr, pixels, 0, width)
The Bitmap is not byte aligned. So in this case when you copy the data in it is filling in the left over bits as black.
the bitmap is 154 bytes wide which creates 19 full bytes and 2 left over pixels. So the remaining 6 pixels are black.
In the end you need to use bitmaps with widths that are divisible by eight or make sure the end of the data copy from the bitmap to pixels(x) accounts for the remaining bytes.
1) remove "7" in this part : width = (bmp.Width + 7) \ 8
2) detect if the bitmap's remaining value after Mod
if(bmp.Width % 8 > 0)
{
var remaining = bmp.Width % 8;
var newbmp = ResizeImage(bmp, bmp.Width + remaining, bmp.Height);
bmp.Dispose();
bmp = newbmp;
}
the logic for ResizeImage
public static Bitmap ResizeImage(Image image, int width, int height)
{
var destRect = new Rectangle(0, 0, width, height);
var oldRect = new Rectangle(0, 0, image.Width, image.Height);
var destImage = new Bitmap(width, height);
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
using (var graphics = Graphics.FromImage(destImage))
{
graphics.FillRectangle(Brushes.White, destRect);
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (var wrapMode = new ImageAttributes())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
graphics.DrawImage(image, oldRect, 0, 0, image.Width, image.Height,
GraphicsUnit.Pixel, wrapMode);
}
}
return destImage;
}
for i = 0 to 23
'' ...
'' create 'line' control
'' ...
line.x1 = (inner_radius*cos(15 * i)) + centerx
line.y1 = (inner_radius*sin(15 * i)) + centery
line.x2 = (outer_radius*cos(15 * i)) + centerx
line.y2 = (outer_radius*sin(15 * i)) + centery
next
I'm using this algorithm to render many line controls to make something like the following:
The result is rather bizarre:
I think this happens due to the rounding of the cos() and sin() functions, so my question is, is there some algorithm I can apply to fix the rounding? Or is there a better way to render such controls, perhaps?
EDIT:
The problem, as pointed by Hrqls was that I was using degrees instead of radians... this is the function that I ended up using:
Sub ProgressAnim(ByVal centerx, _
ByVal centery, _
ByVal outer_radius, _
ByVal inner_radius, _
ByVal step_count, _
ByVal line_width)
Dim pi
Dim degstep
Dim scan
Dim newcontrol As Line
Dim controlid
pi = 4 * Atn(1)
degstep = pi / (step_count / 2)
For scan = 0 To step_count - 1
controlid = "line" & (scan + 1)
Set newcontrol = Me.Controls.Add("vb.line", controlid)
newcontrol.X1 = centerx + (inner_radius * Cos(degstep * scan))
newcontrol.Y1 = centery + (inner_radius * Sin(degstep * scan))
newcontrol.X2 = centerx + (outer_radius * Cos(degstep * scan))
newcontrol.Y2 = centery + (outer_radius * Sin(degstep * scan))
newcontrol.BorderStyle = 1
newcontrol.BorderWidth = line_width
newcontrol.Visible = True
Next
End Sub
Calling it like this
ProgressAnim 150, 250, 16, 9, 18, 1
produces this:
which is much closer to what I expected... sadly, I still don't know how to achieve anti-aliasing, but this will do. (For the moment, at least) :)
Your problem is that you calculate the angles in degrees while VB uses radians for its angles
have a look at the following project :
Option Explicit
Private Sub Form_Click()
DrawWheel
End Sub
Private Sub DrawWheel()
Dim intI As Integer
Dim sngRadius As Single
Dim sngRadiusY As Single
Dim sngCenterX As Single, sngCenterY As Single
Dim sngX1 As Single, sngY1 As Single
Dim sngX2 As Single, sngY2 As Single
Dim sngStep As Single
Dim sngAngle As Single
Dim sngCos As Single, sngSin As Single
'calculate form sizes
sngRadius = (ScaleWidth - 240) / 2
sngRadiusY = (ScaleHeight - 240) / 2
sngCenterX = 120 + sngRadius
sngCenterY = 120 + sngRadiusY
If sngRadiusY < sngRadius Then sngRadius = sngRadiusY
'draw circle
Circle (sngCenterX, sngCenterY), sngRadius
'calculate step between lines
sngStep = Atn(1) / 3
'draw lines
For intI = 0 To 23
'calculate angle for each line
sngAngle = sngStep * intI
'calculate coordinates for each line
sngCos = Cos(sngAngle)
sngSin = Sin(sngAngle)
sngX1 = sngCenterX + sngCos * sngRadius / 10
sngY1 = sngCenterY + sngSin * sngRadius / 10
sngX2 = sngCenterX + sngCos * sngRadius
sngY2 = sngCenterY + sngSin * sngRadius
'draw each lines
Line (sngX1, sngY1)-(sngX2, sngY2)
'print sequence number
Print CStr(intI)
Next intI
End Sub
Click on the form to draw the wheel
Atn(1) is PI/4 ... For 24 lines you need to divide 2*PI by 24 .. thus you need to divide PI by 12 ... which makes you divide Atn(1) by 3
change for i = 0 to 23 to for i = 0 to 21
and (15 * i) with (0.3 * i)
Try that code in form1 with a timer1:
Dim c As Integer, centerx As Integer, centery As Integer, inner_radius As Integer, outer_radius As Integer
Dim x1 As Single, y1 As Single, x2 As Single, y2 As Single
Private Sub Form_Load()
c = 0
centerx = Form1.Width / 2
centery = Form1.Height / 2
inner_radius = 1200
outer_radius = 1
Timer1.Interval = 200
End Sub
Private Sub Timer1_Timer()
x1 = (inner_radius * Cos(0.3 * c)) + centerx
y1 = (inner_radius * Sin(0.3 * c)) + centery
x2 = (outer_radius * Cos(0.3 * c)) + centerx
y2 = (outer_radius * Sin(0.3 * c)) + centery
Line (x1, y1)-(x2, y2), RGB(0, 0, 0)
c = c + 1
If c = 21 Then Timer1.Enabled = False
End Sub
check your numbers in this example to see the drawing behavior.
I would ensure that you keep the greatest accuracy by using proper fractions of 2PI.
Fiddle with the constants until you get roughly what you want:
Option Explicit
Private Sub Form_Load()
Timer.Interval = 50
End Sub
Private Sub Timer_Timer()
DrawRadialLines
End Sub
Private Sub DrawRadialLines()
Const ksngPI As Single = 3.14159!
Const ksngCircle As Single = 2! * ksngPI
Const ksngInnerRadius As Single = 130!
Const ksngOuterRadius As Single = 260!
Const ksngCenterX As Single = 1200!
Const ksngCenterY As Single = 1200!
Const klSegmentCount As Long = 12
Const klLineWidth As Long = 3
Static s_lActiveSegment As Integer ' The "selected" segment.
Dim lSegment As Long
Dim sngRadians As Single
Dim sngX1 As Single
Dim sngY1 As Single
Dim sngX2 As Single
Dim sngY2 As Single
Dim cLineColour As OLE_COLOR
Me.DrawWidth = klLineWidth
' Overdraw previous graphic.
Me.Line (ksngCenterX - ksngOuterRadius - Screen.TwipsPerPixelX * 2, ksngCenterY - ksngOuterRadius - Screen.TwipsPerPixelY * 2)-(ksngCenterX + ksngOuterRadius + Screen.TwipsPerPixelX * 2, ksngCenterY + ksngOuterRadius + Screen.TwipsPerPixelY * 2), Me.BackColor, BF
For lSegment = 0 To klSegmentCount - 1
'
' Work out the coordinates for the line to be draw from the outside circle to the inside circle.
'
sngRadians = (ksngCircle * CSng(lSegment)) / klSegmentCount
sngX1 = (ksngOuterRadius * Cos(sngRadians)) + ksngCenterX
sngY1 = (ksngOuterRadius * Sin(sngRadians)) + ksngCenterY
sngX2 = (ksngInnerRadius * Cos(sngRadians)) + ksngCenterX
sngY2 = (ksngInnerRadius * Sin(sngRadians)) + ksngCenterY
' Work out how many segments away from the "current segment" we are.
' The current segment should be the darkest, and the further away from this segment we are, the lighter the colour should be.
Select Case Abs(Abs(s_lActiveSegment - lSegment) - klSegmentCount \ 2)
Case 0!
cLineColour = RGB(0, 0, 255)
Case 1!
cLineColour = RGB(63, 63, 255)
Case 2!
cLineColour = RGB(117, 117, 255)
Case Else
cLineColour = RGB(181, 181, 255)
End Select
Me.Line (sngX1, sngY1)-(sngX2, sngY2), cLineColour
Next lSegment
' Move the current segment on by one.
s_lActiveSegment = (s_lActiveSegment + 1) Mod klSegmentCount
End Sub
This code does not work I want to create a control array on my Form_Load in VB6 because I have to make 225 of them for a scrabble board and they have to be precise. My code is:
Private lblblocks(1 To 225) As Label
Private Sub Form_Load()
Dim i As Integer, j As Integer
For i = 1 To 15
For j = 1 To 15
Dim arrnum As Integer
arrnum = (i - 1) * 15 + j
Load lblblocks(arrnum)
With lblblocks(arrnum)
.Width = 1000
.Height = 1000
.Top = (i - 1) * 1000
.Left = (j - 1) * 1000
.Visible = True
.BackColor = Int(Rnd(1) * 255) + &H100 * Int(Rnd(1) * 255) + &H10000 * Int(Rnd(1) * 255)
End With
Next j
Next i
End Sub
I used the backcolor to see all my label boxes. This code does not work. I get an error "Object variable or With block variable not set". Any help? I don't know what is wrong. I would like to keep the label boxes in a control array I know how to do it without making it a control array.
Cody Gray had it correct in his comment. I don't believe you can create a control array on the fly only in code in VB6. You have to place one instance of the control on the form and give it an Index property value of zero. This creates a control array with only one element, at index zero. You can then modify your code to produce the desired result, like so:
Private Sub Form_Load()
Dim i As Integer
Dim j As Integer
For i = 0 To 14
For j = 0 To 14
Dim tileIdx As Integer
tileIdx = i * 15 + j
'If the tile index is zero, we already have that control,
'so there's no need to load new instance. Otherwise, use the
'Load method to create a new control in the array with the
'specified index.
If tileIdx > 0 Then
Load lblTile(tileIdx)
End If
With lblTile(tileIdx)
.Width = 1000
.Height = 1000
.Top = i * 1000
.Left = j * 1000
.Visible = True
.BackColor = Int(Rnd(1) * 255) + &H100 * Int(Rnd(1) * 255) + &H10000 * Int(Rnd(1) * 255)
End With
Next
Next
End Sub
As noted in the comment, you don't need to load another instance of the control at array index zero because you did that at design time. I also iterated my array starting from zero for slightly easier calculation of the indices.
we can add from scratch
Private Sub Command3_Click()
Dim rownum As Integer, ColNum As Integer
'Dim lblblocks(1 To 225) As Label
Dim lblblocks() As Label
Dim wwidth As Integer, hheight As Integer
wwidth = 400: hheight = 200
Dim i As Integer, j As Integer
rownum = 20: ColNum = 25
ReDim lblblocks(1 To rownum * ColNum)
For i = 1 To rownum
For j = 1 To ColNum
Dim arrnum As Integer
arrnum = (i - 1) * ColNum + j
Set lblblocks(arrnum) = Me.Controls.Add("VB.Label", "LB" & arrnum)
With lblblocks(arrnum)
'Set Bb(i) = formname.Controls.Add("VB.CommandButton", "Bb" & i)
.Width = wwidth
.Height = hheight
'.Top = (i - 1) * 100
'.Left = (j - 1) * 400
.Top = (i) * hheight
.Left = (j) * wwidth
.Caption = arrnum
.Visible = True
.BackColor = Int(Rnd(1) * 255) + &H100 * Int(Rnd(1) * 255) + &H10000 * Int(Rnd(1) * 255)
End With
Next j
Next i
End Sub
For no particular reason, other than I am interesting in cryptography and computing, I would like to make my own brute force program in Java or Visual Basic or C# to see if it can crack a password. I am not interested in performance and I am aware that it is a totally impractical method - it's just a bit of a fun project to be honest. However, I've only got a rough idea in my head and I can't even put it into psuedocode. I'm most proficient in Java but even if somebody could provide me with the psuedocode that'd be great!
I don't want to provide the program with a length, but I'll provide a maximum length. I know that the program will have to do a lot of work, but I do also think I am overthinking it a little.
The first thing you will want to do is figure out what you want to brute force. I would pick a one way hashing scheme, such as MD5 or SHA-1, that can be brute forced at high rates. After choosing which one way hashing scheme you want to "break", you will have to find some sort of password list, like http://www.whatsmypass.com/the-top-500-worst-passwords-of-all-time. After you have the list you need to hash the values and store them somewhere. After you have this stored "real" data set, you create your brute force loop and compare. When you find a match, output that match. You have now "cracked" a fake person password via brute force. Good luck!
Ok, so I just found an example what I wanted to do in C++ and I've managed to convert it to the following Visual Basic .NET code, which works perfectly. However the output seems a bit slow and I'd have thought the program would have used near 100% processing power, but it isn't. Could somebody tell me why this is and how I could change it please?
Public Class Form1
Dim chars() As Char = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYX".ToCharArray
Dim csize As Integer = chars.Length - 1
Dim upto As String
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
upto = " "
Dim max_length As Integer = 50
For i = 1 To max_length
bf_recursion(0, i)
Update()
Next
End Sub
Private Sub bf_recursion(ByVal index As Integer, ByVal depth As Integer)
Dim current() As Char = upto.ToCharArray()
For i = 0 To csize
current(index) = chars(i)
upto = CStr(current)
Console.WriteLine(CStr(current))
'\\lblOutput.Text = CStr(current)
If index <> (depth - 1) Then
bf_recursion(index + 1, depth)
End If
Next
End Sub
End Class
Hasan-G: yes i can
Dim chars() As Char = "1234567890abcdefghijklmnopqrstuvwxyz".ToCharArray
Dim csize As Integer = chars.Length - 1
Dim upto As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
upto = " "
Dim max_length As Integer = 25
For i = 1 To max_length
bf_recursion(0, i)
Update()
Next
End Sub
Private Sub bf_recursion(ByVal index As Integer, ByVal depth As Integer)
Dim current() As Char = upto.ToCharArray()
For i = 0 To csize
current(index) = chars(i)
upto = CStr(current)
TextBox1.Text = (CStr(current))
TextBox1.Refresh()
Me.Refresh()
'\\lblOutput.Text = CStr(current)
If index <> (depth - 1) Then
bf_recursion(index + 1, depth)
End If
Next
End Sub
while (true)
{
string[] mystring = new string[27];
mystring[0] = "";
mystring[1] = "a";
mystring[2] = "b";
mystring[3] = "c";
mystring[4] = "d";
mystring[5] = "e";
mystring[6] = "f";
mystring[7] = "g";
mystring[8] = "h";
mystring[9] = "i";
mystring[10] = "j";
mystring[11] = "k";
mystring[12] = "l";
mystring[13] = "m";
mystring[14] = "n";
mystring[15] = "o";
mystring[16] = "p";
mystring[17] = "q";
mystring[18] = "r";
mystring[19] = "s";
mystring[20] = "t";
mystring[21] = "u";
mystring[22] = "v";
mystring[23] = "w";
mystring[24] = "x";
mystring[25] = "y";
mystring[26] = "z";
if (counter == 27)
{
counter = 0;
counter2++;
}
if (counter2 == 27)
{
counter2 = 0;
counter3++;
}
if (counter3 == 27)
{
counter3 = 0;
counter4++;
}
if (counter4 == 27)
{
counter4 = 0;
counter5++;
}
if (counter5 == 27)
{
counter5 = 0;
counter6++;
}
if (counter6 == 27)
{
throw new Exception();
}
guessedpassword = mystring[counter6] + mystring[counter5] + mystring[counter4] + mystring[counter3] + mystring[counter2] + mystring[counter];
counter++;
}
Here is some code i have written. It is very inefficient at cracking, but is simple.